public void update(dealer_class dc) { SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=egas;Integrated Security=True;Pooling=False"); SqlDataAdapter da = new SqlDataAdapter("select * from dealer", con); DataSet ds = new DataSet(); da.Fill(ds, "dealer"); cylinder_dealer_keeper cdk = new cylinder_dealer_keeper(); dc._stock_no = cdk.count(dc._id); foreach (DataRow dr in ds.Tables[0].Rows) { if (int.Parse(dr[0].ToString()) == dc._id) { dr.BeginEdit(); dr[1] = dc._name; dr[2] = dc._address; dr[3] = dc._city; dr[4] = dc._state; dr[5] = dc._pincode; dr[6] = dc._stock_no; dr[7] = dc._password; dr[8] = dc._status; dr[9] = dc._contact; dr.EndEdit(); } } SqlCommandBuilder cb = new SqlCommandBuilder(da); da.Update(ds.Tables[0]); }
public dealer_class GetFullDealerData(int id) { SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=egas;Integrated Security=True;Pooling=False"); SqlDataAdapter da = new SqlDataAdapter("select * from dealer", con); DataSet ds = new DataSet(); da.Fill(ds, "dealer"); dealer_class dc = new dealer_class(); foreach (DataRow dr in ds.Tables[0].Rows) { if (int.Parse(dr[0].ToString()) == id) { dc._id = int.Parse (dr[0].ToString ()); dc._name = dr[1].ToString (); dc._address = dr[2].ToString(); dc._city = dr[3].ToString(); dc._state = dr[4].ToString(); dc._pincode = dr[5].ToString(); dc._stock_no = int.Parse (dr[6].ToString()) ; dc._password = dr[7].ToString(); dc._status = dr[8].ToString (); dc._contact = dr[9].ToString(); } } return dc; }