J
Jimmy
Hi all,
I am new to .NET, Any idea that I can't get the below to work?
It gave me this error:
<An unhandled exception of type 'System.Data.SqlClient.SqlException'
occurred in system.data.dll
Additional information: System error.>
Any help would be greatly appreciated.
Assumption: myConnectionString is correctly defined.
----------------------------------------------------
SqlConnection myConn = new SqlConnection(myConnectionString);
SqlDataAdapter myDataAdapter = new SqlDataAdapter();
myDataAdapter.SelectCommand = new SqlCommand("SELECT * FROM customer",
myConn);
SqlCommandBuilder custCB = new SqlCommandBuilder(myDataAdapter);
myDataAdapter.UpdateCommand = custCB.GetUpdateCommand();
myConn.Open();
DataSet custDS = new DataSet();
myDataAdapter.Fill(custDS,myTableName);
//code to modify data in dataset here
//**** NOTE: it go works fine if I take out this line ***//
custDS.Tables[0].Rows[0]["Description"] = "new description";
//**** Error generated here ***
myDataAdapter.Update(custDS, myTableName);
myConn.Close();
----------------------------------------------------------
I am new to .NET, Any idea that I can't get the below to work?
It gave me this error:
<An unhandled exception of type 'System.Data.SqlClient.SqlException'
occurred in system.data.dll
Additional information: System error.>
Any help would be greatly appreciated.
Assumption: myConnectionString is correctly defined.
----------------------------------------------------
SqlConnection myConn = new SqlConnection(myConnectionString);
SqlDataAdapter myDataAdapter = new SqlDataAdapter();
myDataAdapter.SelectCommand = new SqlCommand("SELECT * FROM customer",
myConn);
SqlCommandBuilder custCB = new SqlCommandBuilder(myDataAdapter);
myDataAdapter.UpdateCommand = custCB.GetUpdateCommand();
myConn.Open();
DataSet custDS = new DataSet();
myDataAdapter.Fill(custDS,myTableName);
//code to modify data in dataset here
//**** NOTE: it go works fine if I take out this line ***//
custDS.Tables[0].Rows[0]["Description"] = "new description";
//**** Error generated here ***
myDataAdapter.Update(custDS, myTableName);
myConn.Close();
----------------------------------------------------------