shaheer
shaheer

Reputation: 376

vbs sql help with msaccess

error msg: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

code:

strSQL = "SELECT id,firstname,lastname,username,password, AllowSecureLogin  FROM Staff WHERE 1"

    Dim cmd
    Set cmd                  = Server.CreateObject("ADODB.Command")
    Set cmd.ActiveConnection = dbconn

    With cmd
        .CommandText         = strSQL
        .CommandType         = adCmdText        
    End With

i am no vb/ms access expert please help me

Upvotes: 0

Views: 160

Answers (2)

mwolfe02
mwolfe02

Reputation: 24237

One of the following fields is NOT in your Staff table:

  • id
  • firstname
  • lastname
  • username
  • password
  • AllowSecureLogin

If all of those fields should be there I would double-check that there's not a spelling mistake or typo. Also, PASSWORD is a Jet reserved word. You'll need to enclose it in square brackets in your query:

"SELECT id,firstname,lastname,username,[password],AllowSecureLogin FROM Staff"

Also, your WHERE clause is unnecessary because 1 will always evaluate to True. Unless, of course, that what you really mean is WHERE id = 1.

Upvotes: 2

Chandu
Chandu

Reputation: 82943

Your SQL is wrong.

I think you are trying to get the records where ID=1. If my assumptions is correct change the SQL to(the where clause should be WHERE id = 1):

strSQL = "SELECT id,firstname,lastname,username,password, AllowSecureLogin FROM Staff WHERE id = 1"

Upvotes: 1

Related Questions