flynny
asked on
Return inserted ID from MSSQL insert and TableAdapters
Hi all I have the following code for a paypal ipn handler;
now the InsertRawIPN SQL code in the tableadapter is as follows;
I have set the Execute mode to Scalar, however I am getting the following error;
Error:IPNHandler.aspx.cs: Exception generated inserting to raw_log table :Object reference not set to an instance of an object.:
So it appears to not be returning the identity?
1. Do I need to specifiy the return in the SQL code?
2. Also when inserting I would like to insert the current timestamp to another variable, can i do this in the table adapter SQL code? Coul dsomeone provide an example for me please?
Thanks in advance,
Matt.
int raw_ipn_id = -1;
try
{
using (raw_logTableAdapter rawTable = new raw_logTableAdapter())
{
raw_ipn_id = (int)rawTable.InsertRawIPN(strResponse_copy);
}
}
catch(Exception ex)
{
Global.log.Error(String.Format("Error:IPNHandler.aspx.cs: Exception generated inserting to raw_log table :{0}:", ex.Message));
}
now the InsertRawIPN SQL code in the tableadapter is as follows;
INSERT INTO [raw_log] ([ipn_data_serialized]) VALUES (@ipn_data_serialized);
I have set the Execute mode to Scalar, however I am getting the following error;
Error:IPNHandler.aspx.cs: Exception generated inserting to raw_log table :Object reference not set to an instance of an object.:
So it appears to not be returning the identity?
1. Do I need to specifiy the return in the SQL code?
2. Also when inserting I would like to insert the current timestamp to another variable, can i do this in the table adapter SQL code? Coul dsomeone provide an example for me please?
Thanks in advance,
Matt.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No prob. Thanks for the grade. Good luck with your project. -Jim
ASKER