Hi all,
I am having a wee bit trouble with with the SQL Command Builder. It does not build anything but frustration. From all the books I have read and everything this is how you go about updating changes from dataset or datatable without writing your own updating logic.
Build a sqlconnection
build a sqldata adapter
create a datatable or dataset
build a sqlcommandbuilder object
then have the sqldata adapter fill the dataset or table
make some changes to the dataset or table
use the sqldataadpater.Update method and boom changes should happen.
But if I debug and look at the sqldata adpater under Insert, Update, Delete they are null. Isn't the sqlcommand builder designed to build updating logic on the fly. It builds nothing it seems. What am I doing wrong or has anyone else have the same problem. I know the code works cause I have used it in my ASP.Net applications but won't work with windows app.
private void btnSql_Click(object sender, EventArgs e)
{
//creat a dataset
DataSet dsExcel = new DataSet("Excel");
//create a sql data adapter
SqlDataAdapter sqlDA = new SqlDataAdapter("Select * from ExcelToSql", sqlConn);
//build commands for the damn data adpater so we can update
SqlCommandBuilder sqlComm1 = new SqlCommandBuilder(sqlDA);
//fill the dataset, table called Excel
sqlDA.Fill(dsExcel, "Excel");
//make changes to the dataset
dsExcel.Clear();
//update please work!!!
sqlDA.Update(dsExcel, "Excel");
}//end btnSql_Click
I have even attached a print screen of my laptop in debug mode, look at the highlighted update part. It's null....
Would like to be put in the ritght direction.