hi all
i have completed the task successfully but only one problem where i am wrong i am not knowing
actually i have written code for imageslideshow related to month and day so images are coming from database and sliding related to month and day so this project will run continuosly in system after executing
so if system date changes then the date on which i executed only running still date is changing in system the images related to that date are not sliding
so when i refresh the bowser or stop and debug application again then images coming related to system day and month
finally what i want is actually system date will change every day sowhen sys date changes automatically images coming from database also change not like again refreshing or stopping and debugging application
below is my code any bode suggest me where i am wrong
public partial class separate : System.Web.UI.Page
{
static DataTable dt;
static int TotalRecords, CurrentRecord;
protected void Page_Load(object sender, EventArgs e)
{
//Repeater1.DataSource =GetEvents();
////Repeater1.DataBind();
if (!Page.IsPostBack == true)
{
string sqlconstr = "Data Source=HOME;Initial Catalog=Registration;Integrated Security=True";
SqlConnection con = new SqlConnection(sqlconstr);
SqlDataAdapter sqlda = new SqlDataAdapter("select * from imagepath where CurrentDate is NULL union ALL SELECT * FROM imagepath WHERE month(CurrentDate) =month(CURRENT_TIMESTAMP)And day(CurrentDate) = day(CURRENT_TIMESTAMP)", con);
//SqlDataAdapter sqlda = new SqlDataAdapter("select * from imagepath where CurrentDate is NULL union ALL select * from imagepath where convert(varchar(20), CurrentDate,101) = convert(varchar(20),getdate, 101)", con);
dt = new DataTable();
sqlda.Fill(dt);
TotalRecords = dt.Rows.Count;
Image1.ImageUrl = "~/Upload/" + dt.Rows[0]["ImageName"].ToString();
//Response.Redirect("uploadsite.aspx");
//SqlDataAdapter da1 = new SqlDataAdapter("select ImageName from imagepath where convert(varchar(20), CurrentDate, 101) = convert(varchar(20), getdate(), 101)", sqlconstr);
DataSet ds1 = new DataSet();
SqlDataAdapter da1 = new SqlDataAdapter("select ImageName from imagepath WHERE month(CurrentDate) =month(CURRENT_TIMESTAMP)And day(CurrentDate) = day(CURRENT_TIMESTAMP)", sqlconstr);
da1.Fill(ds1, "imagepath");
string s1 = string.Empty;
if (ds1.Tables["imagepath"].Rows.Count > 0)
{
s1 += " Happy Birthday ";
s1 += ds1.Tables["imagepath"].Rows[0][0].ToString();
}
s1 += " ";
if (ds1.Tables["imagepath"].Rows.Count > 1)
{
s1 += " HappyBirthday ";
s1 += " ";
s1 += ds1.Tables["imagepath"].Rows[1][0].ToString();
}
s1 += " ";
if (ds1.Tables["imagepath"].Rows.Count > 2)
{
s1 += " HappyBirthday ";
s1 += " ";
s1 += ds1.Tables["imagepath"].Rows[2][0].ToString();
}
s1 += " ";
if (ds1.Tables["imagepath"].Rows.Count > 3)
{
s1 += " HappyBirthday ";
s1 += " ";
s1 += ds1.Tables["imagepath"].Rows[3][0].ToString();
}
lt1.Text = s1.ToString();
}
}
// string sqlconstr = "Data Source=HOME;Initial Catalog=Registration;Integrated Security=True";
protected void Timer11_Tick(object sender, EventArgs e)
{
CurrentRecord++;
if (CurrentRecord == TotalRecords)
{
CurrentRecord = 0;
}
Image1.ImageUrl = "~/Upload/" + dt.Rows[CurrentRecord]["newimagepath"].ToString();
// Image1.ImageUrl = "~/Upload/" + dt.Rows[CurrentRecord]["newimagepath"].ToString();
//Image1.ImageUrl = @"C:\Users\admin\Documents\Visual Studio 2012\WebSites\uploadsite\Upload\";
}
}