L
Lynn
HELP! And thanks for any thoughts in advance.
I am writing in C#,
using a SQLExpress database. I am able to retrieve data without a
problem, but I cannot write to the DB. I don't get any error - but the
rows don't appear in the database! It is driving me nuts. There is no
error, no nothing!
Snippet below. Any thoughts at all appreciated.
private static string strConnect =
ConfigurationManager.ConnectionStrings["nmMyNamespace.Properties.Settin
gs.MyConnection_ConnectionString"].ConnectionString;
internal static System.Data.SqlClient.SqlConnection
objConnection = new System.Data.SqlClient.SqlConnection(strConnect);
objConnection.Open();
try
{
if (objConnection.State ==
System.Data.ConnectionState.Open)
{
objCmd = objConnection.CreateCommand();
objTrans =
objConnection.BeginTransaction("InsertRows");
objCmd.Connection = objConnection;
objCmd.Transaction = objTrans;
objCmd.CommandText = strInsertSQL;
objCmd.ExecuteNonQuery();
objTrans.Commit();
return true;
}
}

using a SQLExpress database. I am able to retrieve data without a
problem, but I cannot write to the DB. I don't get any error - but the
rows don't appear in the database! It is driving me nuts. There is no
error, no nothing!
Snippet below. Any thoughts at all appreciated.
private static string strConnect =
ConfigurationManager.ConnectionStrings["nmMyNamespace.Properties.Settin
gs.MyConnection_ConnectionString"].ConnectionString;
internal static System.Data.SqlClient.SqlConnection
objConnection = new System.Data.SqlClient.SqlConnection(strConnect);
objConnection.Open();
try
{
if (objConnection.State ==
System.Data.ConnectionState.Open)
{
objCmd = objConnection.CreateCommand();
objTrans =
objConnection.BeginTransaction("InsertRows");
objCmd.Connection = objConnection;
objCmd.Transaction = objTrans;
objCmd.CommandText = strInsertSQL;
objCmd.ExecuteNonQuery();
objTrans.Commit();
return true;
}
}