473,326 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

What the hell is wrong with the Update statement!

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
Nov 12 '05 #1
3 2842
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


Nov 12 '05 #2
If you are not using an ADO connection then you should try that:

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; " _
& "DBQ=" & Server.MapPath("\yourmdb.mdb")

make sure you have Mdac2.5 and 2.6 loaded on the machine. Then try
treading data from your mdb first. If you can read the data then you
should be able to write the data

strSql = "Select * From tbl1"
Dim RS
Set RS = conn.Execute(strSql)
Do While Not RS.EOF
Response.Write(RS(0).Value & "<br>")
Loop
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
I had a similar problem a few years ago, with VB6. I found that ADO had
a bug that would prohibit using update without moving the cursor. The
recommended fix was to issue a move 0 method before the update. Of
course, you should be using the latest versions, as the others have
suggested.

Martin Wulfe

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

52
by: Tony Marston | last post by:
Several months ago I started a thread with the title "What is/is not considered to be good OO programming" which started a long and interesting discussion. I have condensed the arguments into a...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
2
by: Dan Allen | last post by:
have a lot of questions about ASP.Net. 1. What products do I need from Microsoft to develop and run ASP.NET As background, I currently use Visual InterDev to make ASP applications deployed on...
2
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing to wrong records and I need to fix them using an...
5
by: Koen | last post by:
Hi all, I am experimenting with DAO. I wrote this sub to update one specific field of one specific row in one specific table. Nothing wrong with the SQL statement, but when I execute this I get...
1
by: THY | last post by:
can anyone tell me what's wrong with this statement ? cn.execute("update table set data = 'test'") the asp.net keep telling me syntax error in update statement ... help me please ...
39
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
9
by: rhaazy | last post by:
Using MS SQL 2000 I have a stored procedure that processes an XML file generated from an Audit program. The XML looks somewhat like this: <ComputerScan> <scanheader>...
16
by: SLIMSHIM | last post by:
Hi, I"m new to c# and .net. I wrote a small program to add rows to an access table. the program goes thru the motions but the data never gets there. here is my code. I am intentionaly not using...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.