Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expected end of statement Error (that makes no sense) 1

Status
Not open for further replies.

ElJayWilson

Programmer
Oct 31, 2008
19
US
For the life of me, I cannot figure out why I am getting this error:

Microsoft VBScript Compilation error 800a0401
Expected end of statement
/ajax/ajax.asp line 13
dim myCommand as string = Request.QueryString("cmd")
-----^


Here is my code
Code:
<%
Response.Expires = 0 
Response.Expiresabsolute = Now() - 1 
Response.AddHeader "pragma","no-cache" 
Response.AddHeader "cache-control","private" 
Response.CacheControl = "no-cache" 


' Create connection and command objects
Set cn = New ADODB.Connection
Set cmd = New ADODB.Command
Set rs = New ADODB.Recordset
dim myCommand as string = Request.QueryString("cmd")

select case myCommand
    case "getpatacct"
        dim strConn As String
        dim strSpName as String = "pEreq_Get_PatAcctData"
        dim patAcctNBR as string = Request.QueryString("acctnbr")
        
        strConn = "Provider=SQLOLEDB.1;Password=PASSWORD;Persist Security Info=True;User ID=USER;Initial Catalog=SERVER;Data Source=DB"
        cn.ConnectionString = strConn
        cn.CursorLocation = adUseClient
        cn.Open

        'set the locktype and cursor to cheapest
        rs.LockType = adLockReadOnly
        rs.CursorType = adOpenForwardOnly

        ' Set command properties
        With cmd
            Set .ActiveConnection = cn
            .CommandText = strSpName
            .CommandType = adCmdStoredProc
            Set params = .Parameters
        End With

        ' append the one parameter
        params.Append cmd.CreateParameter("PATACCTNBR", adEmpty, adParamInput, adEmpty, patAcctNBR)

        ' Execute the command
        Set rs = cmd.Execute

       If Not rs.EOF Then
            Response.Write rs(1) & "<br />" & _
            rs(2) &  "<br />" & _
            rs(3) & "<br />" & _
            rs(4) & "<br />" 
       End If


        rs.ActiveConnection = Nothing
        Set rs = Nothing

        Set cmd.ActiveConnection = Nothing
        
    end select
        
cn.Close

Set cmd = Nothing
Set cn = Nothing

I am simply trying to pass a QueryString value to a stored proc and get back information. I have tried not assigning a value at declaration time and I still get the error.

I am lost (and new to ASP)
 
In VBScript, you don't declare variable types. And the assignment of a value must be done in a separate line:
Code:
dim myCommand 
myCommand = Request.QueryString("cmd")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top