G
Guest
Folks
I'm getting a fatal exception thrown when I try to run a parameterized insert query from a SqlDataAdapter. The table I'm appending records to is not the same table that populated the dataset in the first place. In my SQL database, ServiceID and Amount are int 4 and money 8 datafield types, respectively. In my dataset's datatable, the Service column is of type long and Balance is of type decimal.
Nothing shows up in SQL Profiler, so I'm assuming the code is crashing before it even hits the server. Does anybody have any ideas what might be causing this? If so, thank you, thank you, thank you
The SQL statement, pulled from my VS.NET watch list, is as follows: "INSERT INTO tblSupportServiceTransactions (ServiceID, Date, TransactionID, PaymentType, Memo, Amount, Updated, PostedToGL, PostingBatchID, PostingBatchClosed, AccountKey, Received, PaymentCommissionCalculated), Values (@ServiceID, '2/24/2004', 'Regular Payment', 'Web Ccard', 'web visa', @Balance, 0, 0, 14664, 0, 14628, 1, 0);
Exception stack trace is as follows: (reads Greek to me
StackTrace " at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)\r\n at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()\r\n at ClientAccess2.PayOnlineConfirm.PostToBatch() in c:\\inetpub\\wwwroot\\clientaccess2\\payonlineconfirm.aspx.cs:line 400" strin
My Code snippet is as follows
sSQL = "INSERT INTO tblSupportServiceTransactions (ServiceID, Date, TransactionID, PaymentType, Memo, Amount, Updated, PostedToGL, PostingBatchID, PostingBatchClosed, AccountKey, Received, PaymentCommissionCalculated), Values (@ServiceID, '" + DateTime.Now.ToShortDateString() + "', 'Regular Payment', 'Web Ccard', 'web visa', @Balance, 0, 0, " + iPostingBatchID + ", 0, " + sAccountKey + ", 1, 0);"
cmd = cn.CreateCommand()
cmd.CommandText = sSQL
cmd.Parameters.Add("@ServiceID", SqlDbType.Int, 4, "ServiceID")
cmd.Parameters.Add("@Balance", SqlDbType.Money, 8, "Balance")
cmd.Parameters["@ServiceID"].Value = CustScreen.dsMyData.Balance.Columns["ServiceID"]
cmd.Parameters["@Balance"].Value = CustScreen.dsMyData.Balance.Columns["Balance"]
cmd.ExecuteNonQuery()
I'm getting a fatal exception thrown when I try to run a parameterized insert query from a SqlDataAdapter. The table I'm appending records to is not the same table that populated the dataset in the first place. In my SQL database, ServiceID and Amount are int 4 and money 8 datafield types, respectively. In my dataset's datatable, the Service column is of type long and Balance is of type decimal.
Nothing shows up in SQL Profiler, so I'm assuming the code is crashing before it even hits the server. Does anybody have any ideas what might be causing this? If so, thank you, thank you, thank you
The SQL statement, pulled from my VS.NET watch list, is as follows: "INSERT INTO tblSupportServiceTransactions (ServiceID, Date, TransactionID, PaymentType, Memo, Amount, Updated, PostedToGL, PostingBatchID, PostingBatchClosed, AccountKey, Received, PaymentCommissionCalculated), Values (@ServiceID, '2/24/2004', 'Regular Payment', 'Web Ccard', 'web visa', @Balance, 0, 0, 14664, 0, 14628, 1, 0);
Exception stack trace is as follows: (reads Greek to me
StackTrace " at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)\r\n at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()\r\n at ClientAccess2.PayOnlineConfirm.PostToBatch() in c:\\inetpub\\wwwroot\\clientaccess2\\payonlineconfirm.aspx.cs:line 400" strin
My Code snippet is as follows
sSQL = "INSERT INTO tblSupportServiceTransactions (ServiceID, Date, TransactionID, PaymentType, Memo, Amount, Updated, PostedToGL, PostingBatchID, PostingBatchClosed, AccountKey, Received, PaymentCommissionCalculated), Values (@ServiceID, '" + DateTime.Now.ToShortDateString() + "', 'Regular Payment', 'Web Ccard', 'web visa', @Balance, 0, 0, " + iPostingBatchID + ", 0, " + sAccountKey + ", 1, 0);"
cmd = cn.CreateCommand()
cmd.CommandText = sSQL
cmd.Parameters.Add("@ServiceID", SqlDbType.Int, 4, "ServiceID")
cmd.Parameters.Add("@Balance", SqlDbType.Money, 8, "Balance")
cmd.Parameters["@ServiceID"].Value = CustScreen.dsMyData.Balance.Columns["ServiceID"]
cmd.Parameters["@Balance"].Value = CustScreen.dsMyData.Balance.Columns["Balance"]
cmd.ExecuteNonQuery()