L
Lynn
I wrote the plea below several days ago and got some good help. Thanks
to Robin, who responded and helped me solve a real hair-puller for me.
Now I have a different question: the changes are appearing in my dB,
and all are ok except my dates don't go in. I have tthree date fields,
and all of them are defined as "not null". When I view the table, the
value for all added records in the date fields is 1/1/1900. That
surely is the default value. I am, indeed, sending valid dates, at
least they loook valid to me, adn all values in other fields are being
added without a problem. For the dates, though they are not being
added, I receive no error. What is it with SQL Express that misbehaves
but never reports an error? Snippet here. Any help appreciated, and
thanks again to all.
strInsertSQL = "Insert into TCSTPSUMM00
(EMPL_NUM,PYRL_NO,PERIOD_DATE,STEP_DATE,POINTS_QTY,PROCESS_DATE)
values (11111, 25,1/1/2005, 11/19/2002, 4,2/2/2005)";
SqlTransaction objTrans = null;
SqlCommand objCmd = null;
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;
}
}
Thanks again to all.
===================================
THANKS FOR HELP ON THIS ONE. - DONE!
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;
}
}
to Robin, who responded and helped me solve a real hair-puller for me.
Now I have a different question: the changes are appearing in my dB,
and all are ok except my dates don't go in. I have tthree date fields,
and all of them are defined as "not null". When I view the table, the
value for all added records in the date fields is 1/1/1900. That
surely is the default value. I am, indeed, sending valid dates, at
least they loook valid to me, adn all values in other fields are being
added without a problem. For the dates, though they are not being
added, I receive no error. What is it with SQL Express that misbehaves
but never reports an error? Snippet here. Any help appreciated, and
thanks again to all.
strInsertSQL = "Insert into TCSTPSUMM00
(EMPL_NUM,PYRL_NO,PERIOD_DATE,STEP_DATE,POINTS_QTY,PROCESS_DATE)
values (11111, 25,1/1/2005, 11/19/2002, 4,2/2/2005)";
SqlTransaction objTrans = null;
SqlCommand objCmd = null;
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;
}
}
Thanks again to all.
===================================
THANKS FOR HELP ON THIS ONE. - DONE!
HELP! And thanks for any thoughts in advance.

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;
}
}