T
trint
I am trying to insert a record, but I have to get an automatically
created identity field at the same time to do this.
string strSQL2 = "INSERT INTO tblTravelDetail(MemberID, " +
" TravelEventID, " +
" CreatedDateTime, " +
" Operator) " +
"VALUES ('" + TxtMLV.Text.Trim() + "', " +
" '" + TxtEventID+ "', " +
" '" + TxtDATE.Text.Trim() + "', " +
" '" + "operator name" + "') " +
"SELECT @@IDENTITY AS TravelDetailID" ;
This code doesn't work because it causes this error:
An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in db2sql.exe
Additional information: INSERT statement conflicted with COLUMN FOREIGN
KEY constraint 'FK_tblTravelDetail_tblTravelEvent'. The conflict
occurred in database 'tsNess', table 'tblTravelEvent', column
'TravelEventId'.
What will I have to do to do get a handle on this? I have been doing
INSERT for two years with vb.net and c#, but this has me puzzled what
to do next.
Thanks,
Trint
created identity field at the same time to do this.
string strSQL2 = "INSERT INTO tblTravelDetail(MemberID, " +
" TravelEventID, " +
" CreatedDateTime, " +
" Operator) " +
"VALUES ('" + TxtMLV.Text.Trim() + "', " +
" '" + TxtEventID+ "', " +
" '" + TxtDATE.Text.Trim() + "', " +
" '" + "operator name" + "') " +
"SELECT @@IDENTITY AS TravelDetailID" ;
This code doesn't work because it causes this error:
An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in db2sql.exe
Additional information: INSERT statement conflicted with COLUMN FOREIGN
KEY constraint 'FK_tblTravelDetail_tblTravelEvent'. The conflict
occurred in database 'tsNess', table 'tblTravelEvent', column
'TravelEventId'.
What will I have to do to do get a handle on this? I have been doing
INSERT for two years with vb.net and c#, but this has me puzzled what
to do next.
Thanks,
Trint