> SqlCommand sc = new SqlCommand(); > sc.Connection = this.oConnection; > sc.Connection.Open(); > foreach (DataRow Row in ds.Tables[0].Rows) > { > switch (Row.RowState) > { > case DataRowState.Added : > // or use a StoredProc, which I prefer > sc.CommandText = "Insert into bob (xyz, abc) VALUES ( @xyz, @abc )"; > sc.Parameters.Clear(); > sc.Parameters.Add("@xyz", Row["xyz"]); > sc.Parameters.Add("@abc", Row["abc"]); > sc.ExecuteNonQuery(); > break; > > // Do the same for DataRowState Deleted and Modified > case DataRowState.Deleted : > break; > case DataRowState.Modified : > break; > } > } > sc.Connection.Close(); > >>
>sc.CommandText = "Insert into bob (xyz, abc) VALUES ( @xyz, @abc )";
>
>>SqlCommand sc = new SqlCommand(); >sc.CommandText = "Insert into bob (xyz, abc) VALUES ( @xyz, @abc )"; <<<--------------- >sc.Connection = this.oConnection; >sc.Connection.Open(); >foreach (DataRow Row in ds.Tables[0].Rows) >{ >. >. >. >>