2
Answers

how to retrive data from database in c#.net

jeevan mummadi

jeevan mummadi

16y
7.9k
1

this is my table

rate            total            time             date   

2.666541   0015744     16:17:37     16-05-08

i can wrote code like this  for retreving

SqlConnection con = new SqlConnection("server=localhost;initial catalog=online_application1;user id=sa;pwd=");

con.Open();

string st = "

select total from packet where date=" + date + "

";

DataSet ds = new DataSet();

DataRow dr;

DataTable dt;

SqlDataAdapter da = new SqlDataAdapter(st, con);

da.Fill(ds, "packet");

dt = ds.Tables[0];

recptr = dt.Rows.Count - 1;

dr = dt.Rows[recptr];

string yes = dr1[0].ToString();

i want retrive data from above table where date=16-05-08

but i getting this error

 

An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code

Additional information: Syntax error converting the varchar value '14-05-08' to a column of data type int.

plz help ...or any other method to retrive data

 

 

Answers (2)
Next Recommended Forum