>//Example 1: >string lc_conn = "Integrated Security=SSPI;" + > "Initial Catalog=mydatabase;"; > >string SelectCmd = "SELECT * FROM roster"; >SqlConnection myConnection = new SqlConnection(lc_conn); >SqlDataAdapter da = new SqlDataAdapter(); >SqlCommand mycommand = new SqlCommand(SelectCmd, myConnection); >da.SelectCommand = mycommand; >DataSet ds = new DataSet(); >da.Fill(ds, "roster"); >string lc_sql = "INSERT INTO roster (ro_name) Values('name 1')"; >mycommand = new SqlCommand(lc_sql, myConnection); >da.InsertCommand = mycommand; >da.Update(ds, "roster"); > >//Example 2: >string lc_conn = "Integrated Security=SSPI;" + > "Initial Catalog=mydatabase;"; > >SqlConnection myconn = new SqlConnection(lc_conn); >SqlDataAdapter da = new SqlDataAdapter("select * from roster", myconn); >DataSet ds = new DataSet(); >DataRow mydatarow; > >SqlCommandBuilder mySqlCommandBuilder = new SqlCommandBuilder(da); >da.MissingSchemaAction = MissingSchemaAction.AddWithKey; >da.Fill(ds, "roster"); >mydatarow = ds.Tables["roster"].NewRow(); >mydatarow["ro_name"] = "Name 1"; > >ds.Tables["roster"].Rows.Add(mydatarow); > >>