access_asp thread: Chapter 14 Try It Out #5 ? Passing values to an Access action stored procedure
Hi there,
I changed the connection from DSN (which works) to OLE DB (which doesn't
for me?)
The Error
Description: Invalid SQL statement;
expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
Source: Microsoft JET Database Engine
How do I get code work with an ole db connection?
Here is the query code
PARAMETERS Name Text ( 255 ), Class Text ( 255 ), Launched DateTime,
Certified Bit, Notes Text, [Value] Currency;
INSERT INTO Boats ( BoatName, BoatClass, BoatLaunched, BoatCertified,
BoatNote, BoatValue )
SELECT [Name] AS Expr1, [Class] AS Expr2, [Launched] AS Expr3, [Certified]
AS Expr4, [Notes] AS Expr5, [Value] AS Expr6;
Here is the ASP main code
'Create and open the database object
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
& Server.Mappath("../databases/sailors.mdb") & ";"
objConn.Open
'Declare variables and set their values
Dim adCmdText
Dim strClass
Dim lngLength
Dim lngWeight
Dim lngMainJib
Dim lngSpinnaker
Dim strAuthority
adCmdText = 1
strClass = "Mini Laser"
lngLength = 3
lngWeight = 45
lngMainJib = 6
lngSpinnaker = 0
strAuthority = "www.laser.com"
'Create the command object and set the query to be executed
Set objCmd = Server.CreateObject("ADODB.Command")
Set objCmd.ActiveConnection = objConn
objCmd.CommandText = "{call qparmInsertBoatClass ('" & CStr(strClass) & _
"'," & CLng(lngLength) & "," & CLng(lngWeight) & _
"," & CLng(lngMainJib) & "," & CLng(lngSpinnaker) & _
",'" & CStr(strAuthority) & "')}"
objCmd.CommandType = adCmdText
objCmd.Execute
'Close and dereference database objects
objConn.Close
Set objConn = Nothing
Cheers
Matt