I'm getting the following error: I need to insert a record into one table, grab the autonumber key (Register_ID)and insert multiple records into another table with the key. Does anyone know why I'm getting this error and how I can correct it?
ADODB.Connection error '800a0bb9'
The application is using arguments that are of the wrong type, are out of acceptable range, or are in conflict with one another.
/Check2/submit_registration.asp, line 44
Line 44 is:
connupdate.Open "WebRegister", strProvider, adOpenKeySet, adLockPessimistic
Here is my code:
<% Option Explicit %>
<!-- #include file="adovbs.inc" -->
<% Response.buffer = True%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<%
Dim aCatIds, _
aSubCatIds
Dim iGroupId, _
iCntCatId, _
iCntSubCatId, _
iSubCatId, _
iRegisterId
Dim strNotify
Dim sFld, _
sSql
Dim strProvider
Dim connupdate
sSql = "INSERT INTO Webregister (Company_Name, St_Address, City, State, Zip, Phone_Num, Fax_Num, Web_Site, Contact_Person, Contact_Phone, Contact_Email, Respond_Da, E_Notify) Values ('" & Replace(Request.Form("D_Company"
, "'", ""
& "','" & Replace(Request.Form("D_Address"
, "'", ""
& "','" & Replace(Request.Form("D_City"
, "'", ""
& "','" & Replace(Request.Form("D_State"
, "'", ""
& "','" & Replace(Request.Form("D_Zip"
, "'", ""
& "','" & Replace(Request.Form("D_Phone"
, "'", ""
& "','" & Replace(Request.Form("D_Fax"
, "'", ""
& "','" & Replace(Request.Form("D_Website"
, "'", ""
& "','" & Replace(Request.Form("D_Contact"
, "'", ""
& "','" & Replace(Request.Form("D_CPhone"
, "'", ""
& "','" & Replace(Request.Form("D_Email"
, "'", ""
& "','" & Replace(Request.Form("hidDate"
, "'", ""
& "','" & Request.Form("notify"
& "')"
set connupdate = server.createobject("ADODB.Connection"
strProvider="Provider=MSDASQL.1;Persist Security Info=False;Data Source=Registration"
connupdate.Open "WebRegister", strProvider, adOpenKeySet, adLockPessimistic
connupdate.execute(sSql)
'execute SQL statement, get newly created RegisterId
iRegisterID = connupdate("Register_ID"
aCatIds = Split(Request.Form("GroupID"
, ", "
For iCntCatId = 0 To UBound(aCatIds)
iGroupId = aCatIds(iCntCatId)
aSubCatIds = Split(Request.Form("SubCatId_" & iGroupId), ", "
For iCntSubCatId = 0 To UBound(aSubCatIds)
iSubCatId = aSubCatIds(iCntSubCatId)
sSql = "INSERT INTO WebCommodities (Register_ID, GroupID, SubCategory) Values(" & vbCrLf & _
" " & iRegisterId & "," & vbCrLf & _
" " & iGroupId & "," & vbCrLf & _
" " & iSubCatId & vbCrLf & _
"
"
connupdate.execute(sSql)
Next
Next
connupdate.close
set connupdate = nothing
%>
</BODY>
</HTML>
ADODB.Connection error '800a0bb9'
The application is using arguments that are of the wrong type, are out of acceptable range, or are in conflict with one another.
/Check2/submit_registration.asp, line 44
Line 44 is:
connupdate.Open "WebRegister", strProvider, adOpenKeySet, adLockPessimistic
Here is my code:
<% Option Explicit %>
<!-- #include file="adovbs.inc" -->
<% Response.buffer = True%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<%
Dim aCatIds, _
aSubCatIds
Dim iGroupId, _
iCntCatId, _
iCntSubCatId, _
iSubCatId, _
iRegisterId
Dim strNotify
Dim sFld, _
sSql
Dim strProvider
Dim connupdate
sSql = "INSERT INTO Webregister (Company_Name, St_Address, City, State, Zip, Phone_Num, Fax_Num, Web_Site, Contact_Person, Contact_Phone, Contact_Email, Respond_Da, E_Notify) Values ('" & Replace(Request.Form("D_Company"
set connupdate = server.createobject("ADODB.Connection"
strProvider="Provider=MSDASQL.1;Persist Security Info=False;Data Source=Registration"
connupdate.Open "WebRegister", strProvider, adOpenKeySet, adLockPessimistic
connupdate.execute(sSql)
'execute SQL statement, get newly created RegisterId
iRegisterID = connupdate("Register_ID"
aCatIds = Split(Request.Form("GroupID"
For iCntCatId = 0 To UBound(aCatIds)
iGroupId = aCatIds(iCntCatId)
aSubCatIds = Split(Request.Form("SubCatId_" & iGroupId), ", "
For iCntSubCatId = 0 To UBound(aSubCatIds)
iSubCatId = aSubCatIds(iCntSubCatId)
sSql = "INSERT INTO WebCommodities (Register_ID, GroupID, SubCategory) Values(" & vbCrLf & _
" " & iRegisterId & "," & vbCrLf & _
" " & iGroupId & "," & vbCrLf & _
" " & iSubCatId & vbCrLf & _
"
connupdate.execute(sSql)
Next
Next
connupdate.close
set connupdate = nothing
%>
</BODY>
</HTML>