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!

trouble updating database .... PLEASE HELP!

Status
Not open for further replies.

crymedry

MIS
Nov 19, 2003
54
0
0
ok, i have been working on this code for forever it seems, and i can't figure out what is wrong.

all i am trying to do is update a database record, here is the code:

'define sql statements
StrInsert="UPDATE Issues SET [_detailSituation]=" & frm_misDetail & ", [_solution]=" & frm_misDetail & ", [_status]=" & frm_misStatus & " WHERE [_id] = "& frm_misId &""

'create a connection
Set objConn=Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=miskb"
Set objCmd=Server.CreateObject("ADODB.Command")
Set objCmd.ActiveConnection=objConn
objCmd.CommandText= ""&StrInsert&""


'execute the statements above
objCmd.Execute

and here is the error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/Scripts/mis/mis_update.asp, line 50


line fifty is the last line of code i placed up there .... any help would be greatly appreciated.

thanks in advance!!!
 
hey there - i think you might be complicating the process =p The KISS way of doing it might be:

Set con = Server.CreateObject("ADODB.Connection")
con.Open db_ConnectionString

sql = "Update ..."
con.execute (sql)

I dont use the syntax you are using but
two quotes in vb relate to empty string so - ""&StrInsert&"" is just app/prepending empty strings - ie. doing nothing. If you wanted to append a quote you need 3 ie
"""& string & """

cheers
 
i tried it that way .... i still get the same error ... "to few parameters"

what else can i do?
 
Try changing the query to:

StrInsert="UPDATE Issues SET [_detailSituation]='" & frm_misDetail & "', [_solution]='" & frm_misDetail & "', [_status]='" & frm_misStatus & "' WHERE [_id] = "& frm_misId &" "

-observe the single quotes....

-VJ
 
yep amorous is right - when you are updating varchars in sql you need to single quote.

But the best thing to do is :
response.write sqlquery

Get the output from that and pop it into query analyser or some other sql program (dbartisan etc.) and check the validity of the sql statement generated... You will get meaningful error messages then...
 
For later reference, the reason you gt this error is that Acess was seeing some words in te statement that were not known functions or field name, so it wanted to treat them as variables. Since it didn't have values forthose variables it kindly asked you to put some in. Generally if you see this error it means one of two things: a) you mispelled a field name or havea fieldname in your statement that doesn't exist in your table, or b) you are missing some quotes around a string value somewhere.

In this case I think amorous hit the nail on the head, but I wanted to supply the info in case you run into this again.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top