Hello people!
Ok, here's a little problem that I've been having with in VBScript and SQL. I have multiple text fields where I will be inputting serial numbers or "rug IDs" followed by a submit button. Upon hitting the button, this VBScript is supposed to connect to the database and do the following steps:
1. Call up a field from the database called "BaleNum" or bale number.
2. Add 1 to the pre-existing "BaleNum".
3. Take in all the serial numbers and enter them as new records in the field called "VendorRugID". At the same time, the Bale number or "BaleNum" is assigned to that serial number.
So in essence, there are multiple rugs that each have a serial number. Each serial number is assigned a bale number (hence like bales of hay, bales of rugs). Unfortunately I run into a little problem when I try to test it out...the browser (IE 5.5) says I have this problem:
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
/rugs/test.asp, line 32
Can anyone help me? The coding is as follows! Thank you!
<%
Dim i, v1, v2, v3, r
Set MM_insertCmd = Server.CreateObject("ADODB.Command"
MM_insertCmd.ActiveConnection = "dsn=Glen;"
If len(Request.QueryString("rugID") > 0 then
strSelect = "SELECT MAX(BaleNum) FROM Test"
strSelect = "UPDATE Test SET BaleNum = '"&strSelect&"+1'"
End If
For i = 1 To 3
r = Cstr(Request.Form("rugID" & i ))
If r <> "" Then
v1 = "INSERT Test(VendorRugID, BaleNum) VALUES('"&r&"', '"&strSelect&"')"
MM_insertCmd.CommandText = v1
MM_insertCmd.Execute
End If
Next
%>
Ok, here's a little problem that I've been having with in VBScript and SQL. I have multiple text fields where I will be inputting serial numbers or "rug IDs" followed by a submit button. Upon hitting the button, this VBScript is supposed to connect to the database and do the following steps:
1. Call up a field from the database called "BaleNum" or bale number.
2. Add 1 to the pre-existing "BaleNum".
3. Take in all the serial numbers and enter them as new records in the field called "VendorRugID". At the same time, the Bale number or "BaleNum" is assigned to that serial number.
So in essence, there are multiple rugs that each have a serial number. Each serial number is assigned a bale number (hence like bales of hay, bales of rugs). Unfortunately I run into a little problem when I try to test it out...the browser (IE 5.5) says I have this problem:
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
/rugs/test.asp, line 32
Can anyone help me? The coding is as follows! Thank you!
<%
Dim i, v1, v2, v3, r
Set MM_insertCmd = Server.CreateObject("ADODB.Command"
MM_insertCmd.ActiveConnection = "dsn=Glen;"
If len(Request.QueryString("rugID") > 0 then
strSelect = "SELECT MAX(BaleNum) FROM Test"
strSelect = "UPDATE Test SET BaleNum = '"&strSelect&"+1'"
End If
For i = 1 To 3
r = Cstr(Request.Form("rugID" & i ))
If r <> "" Then
v1 = "INSERT Test(VendorRugID, BaleNum) VALUES('"&r&"', '"&strSelect&"')"
MM_insertCmd.CommandText = v1
MM_insertCmd.Execute
End If
Next
%>