//Initialize Connection from database
SqlConnection cn = new SqlConnection("connectionString");
//add this Query command with connectionstring parameters to data adopter to get schema form database
SqlDataAdapter da = new SqlDataAdapter("Select * from tablename",cn);
// Dataset Object
DataSet ds = new DataSet();
//fill database schema to dataset
da.FillSchema(ds, SchemaType.Mapped);
DataRow dRow1 = ds.Tables["workers"].NewRow();
dRow1[1] = "Value1"; //textBox1.Text;
dRow1[2] ="Value2"; //textBox2.Text;
dRow1[3] ="Value3";///textBox3.Text;
dRow1[4] = "Value4";///textBox4.Text;
dRow1[5] = "Value5";//textBox5.Text;
ds.Tables["workers"].Rows.Add(dRow1);
SqlCommandBuilder builder = new SqlCommandBuilder(da);
da.Update(ds);
ds.AcceptChanges();
0 comments:
Post a Comment