Hi,
I am having a major problem when doing a database insert using the following code (I've done response.write for debugging):
-----------------
Set RS = idConn.execute("INSERT INTO tblIntraCal(txtType, txtNotes, Createdon, Modifiedon, userID) VALUES ('" & MyType & "' ,'" &_
Replace(MyNotes, chr(34), "") & "', CAST('" & Date() & " " & Time() & "' AS DATETIME), CAST('" & Date() & " " & Time() & "' AS DATETIME), " &_
UserID & "); SELECT @@identity").nextrecordset
Response.Write "INSERT INTO tblIntraCal(txtType, txtNotes, Createdon, Modifiedon, userID) VALUES ('" & MyType & "' ,'" &_
Replace(MyNotes, chr(34), "") & "', CAST('" & Date() & " " & Time() & "' AS DATETIME), CAST('" & Date() & " " & Time() & "' AS DATETIME), " &_
UserID & "); SELECT @@identity" & vbcrlf
SQLNextID = CInt(RS(0))
Response.Write SQLNextID
Set RS = Nothing
For i = 1 to Request.Form("checker").count
Response.Write Request.Form("checker")(i) & vbcrlf
If Request.Form("checker")(i) <> "" Then MyString = MyString & "INSERT INTO tblIntraCalDates(nID, dateCAL) VALUES (" & SQLNextID & ",'" & CDate(Request.Form("checker")(i)) & "')"
Next
idConn.execute(MyString)
If Err.Number <> 0 then
idConn.RollbackTrans
Response.Write "An error occured with this transaction, Contact Admin!" & Err.Description
idConn.close
Set idConn = Nothing
Else
idConn.CommitTrans
idConn.close
Set idConn = Nothing
'Response.Redirect("holiday.asp?uname=" & UserID)
End If
---------------------------------
For some reason SOMETIMES both SQL statements execute twice and putting values in both tables twice?!?!
On the previous screen that is submitted I have a year planner with lots of check boxes to select days of the year (each check box has a different date value).
The response.write output is correct and doesn't show any doubling up.
Hope someone can understand and help us.
Thanks.
I am having a major problem when doing a database insert using the following code (I've done response.write for debugging):
-----------------
Set RS = idConn.execute("INSERT INTO tblIntraCal(txtType, txtNotes, Createdon, Modifiedon, userID) VALUES ('" & MyType & "' ,'" &_
Replace(MyNotes, chr(34), "") & "', CAST('" & Date() & " " & Time() & "' AS DATETIME), CAST('" & Date() & " " & Time() & "' AS DATETIME), " &_
UserID & "); SELECT @@identity").nextrecordset
Response.Write "INSERT INTO tblIntraCal(txtType, txtNotes, Createdon, Modifiedon, userID) VALUES ('" & MyType & "' ,'" &_
Replace(MyNotes, chr(34), "") & "', CAST('" & Date() & " " & Time() & "' AS DATETIME), CAST('" & Date() & " " & Time() & "' AS DATETIME), " &_
UserID & "); SELECT @@identity" & vbcrlf
SQLNextID = CInt(RS(0))
Response.Write SQLNextID
Set RS = Nothing
For i = 1 to Request.Form("checker").count
Response.Write Request.Form("checker")(i) & vbcrlf
If Request.Form("checker")(i) <> "" Then MyString = MyString & "INSERT INTO tblIntraCalDates(nID, dateCAL) VALUES (" & SQLNextID & ",'" & CDate(Request.Form("checker")(i)) & "')"
Next
idConn.execute(MyString)
If Err.Number <> 0 then
idConn.RollbackTrans
Response.Write "An error occured with this transaction, Contact Admin!" & Err.Description
idConn.close
Set idConn = Nothing
Else
idConn.CommitTrans
idConn.close
Set idConn = Nothing
'Response.Redirect("holiday.asp?uname=" & UserID)
End If
---------------------------------
For some reason SOMETIMES both SQL statements execute twice and putting values in both tables twice?!?!
On the previous screen that is submitted I have a year planner with lots of check boxes to select days of the year (each check box has a different date value).
The response.write output is correct and doesn't show any doubling up.
Hope someone can understand and help us.
Thanks.