3 points...
1. The error you are getting indicates that something in your query is not
resolving to the name of a field in a table. Paste it into a query in the
Access database, try to run it, and see what it asks you for. This should
help you find the problem.
2. When executing a command that returns no records, it's best to say so, or
some errors will not be detectable from VB/VBA. Use the adExecuteNoRecords
option to the Execute method.
3. Inserting text the user types directly into SQL is very dangerous,
especially for a Web app. Instead, you should use parameters. Assuming this
is ADO, the code would be something like this...
sqlString = _
"UPDATE dialup SET password = ?, " & _
"username = ? " & _
"WHERE k = ?"
With New ADODB.Command
Set .ActiveConnection = con
.CommandType = adCmdText
.CommandText = sqlString
.Parameters.Append .CreateParameter( _
"prmPassword", adVarChar, adParamInput, 20, password)
.Parameters.Append .CreateParameter( _
"prmUserName", adVarChar, adParamInput, 20, username)
.Parameters.Append .CreateParameter( _
"prmK", adInteger, adParamInput, , k)
.Execute adExecuteNoRecords
End With
On 18 Feb 2004 08:59:54 -0800,
na******@hotmail.com (Natthera) wrote:
Writing this for a webpage using ASP. I simply want to update to
fields in an Access 2000 DB:
sqlString = "UPDATE dialup SET password = '" & password & "' ,
username = '" & username & "' WHERE k = " & k
Con.Execute sqlString
Password and username are strings, k is a number.
Whenever I run it I get this error:
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected
1.
Now, when I response.write sqlString, it seems fine. All variable are
showing up. I simply can't get past this error message.
What am I missing?
NY