c# - Difference Between DataReader and Dataset? -


i want convert code using dataset.

i don't have idea how retrieve data dataset.

 conn.open();   string strquery = "select * tblclientinfo clientid=" +  txtid.text; sqlcommand sqlcmd = new sqlcommand(strquery, conn);   sqldatareader sqldreader = sqlcmd.executereader();   if (sqldreader.hasrows)  {     while (sqldreader.read())     {        txtid.text = sqldreader["clientid"].tostring();        txtname.text = sqldreader["name"].tostring();        txtmobile.text = sqldreader["mobile"].tostring();        txtcnic.text = sqldreader["cnic"].tostring();     }  }  else  {     messagebox.show("record id" + " " + txtid.text + " " + "not found !");  }   sqldreader.close();  conn.close(); 

do want ?

sqldataadapter da = new sqldataadapter(); da.selectcommand.commandtext = "select * tblclientinfo clientid = @id"; da.selectcommand.parameters.addwithvalue("@id", txtid); da.selectcommand.connection = conn; dataset ds = new dataset(); da.fill(ds);  foreach (datarow row in ds.tables[0].rows) {    txtid.text = row["clientid"].tostring();    txtname.text = row["name"].tostring();     ... } 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -