view records in asp.net

Posted by Dn2010 under ASP.NET on 4/4/2012 | Points: 10 | Views : 959 | Status : [Member] | Replies : 0
hi friends,

datetime in Label1 from db, compare the date of Label1(last_datetime) in gridview and View records after the Label1(last_datetime) datetime.

please correct the code,

string CommandText = "SELECT DATE_FORMAT(calldate,'%Y%-%m-%d %H:%I:%s.000') as calldate,userfield FROM data WHERE calldate BETWEEN '" + last_datetime + "' And CURDATE() Order By calldate desc limit 20";


1: filled date in Label1.text in page loag

SqlDataAdapter da = new SqlDataAdapter("select top 1 calldate from data", con);
DataTable dt = new DataTable();
da.Fill(dt);

if (dt.Rows.Count > 0)
{
Label1.Text = String.Format("{0:yyyy-MM-dd HH:mm:ss.fff }", Convert.ToDateTime(dt.Rows[0][0].ToString()));




public void fillgrid()
{
DateTime last_datetime = Convert.ToDateTime(Label1.Text);


string ConnectionString = @"driver={MySQL ODBC 3.51 Driver};server=" + ServerName + ";database=" + databasename + ";uid=" + UserName + "; pwd= " + password + "; ";

string CommandText = "SELECT DATE_FORMAT(calldate,'%Y%-%m-%d %H:%I:%s.000') as calldate,userfield FROM data WHERE calldate BETWEEN '" + last_datetime + "' And CURDATE() Order By calldate desc limit 20";


OdbcConnection myConnection = new OdbcConnection(ConnectionString);
OdbcCommand myCommand = new OdbcCommand(CommandText, myConnection);

myConnection.Open();

GridView1.DataSource = myCommand.ExecuteReader();
GridView1.DataBind();

myConnection.Close();
}


please give the solution for this.

thanks..

thanks.




Responses

(No response found.)

Login to post response