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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Errors with Update SQL Statement

Status
Not open for further replies.

codegirl

Technical User
Feb 9, 2003
13
US
I already tried to add this thread but I don't believe it saved it, so I hope this isn't a double post!

Anyway I am having problems updating my database. I'm using VB, and I'm pretty sure the error is in the query itself because I'm using the same connection code that I've used in several other functions without errors. But just so you can see what I'm doing, here's the VB code first:

Dim conResult As New ADODB.Connection
Dim cmdResult As New ADODB.Command
Dim strUpdate As String

<Build SQL statement in strUpdate>

'Establish a connection with the database
conResult.mode = adModeShareDenyNone
conResult.CursorLocation = adUseClient
conResult.ConnectionString = &quot;DSN=myDSN&quot;
conResult.Open

'Execute the update statement
Set cmdResult.ActiveConnection = conResult
cmdResult.CommandType = adCmdText
cmdResult.CommandText = strUpdate
cmdResult.Execute

Here are the contents of strUpdate, copied straight from the Immediate Window:

UPDATE Invoice SET Invoice_ID = 1, Requester_ID = 1, Hospital_ID = 123, State = 'MO', Invoice_Date = #12/1/2003#, Claim = 'F9002', Patient_FName = 'John', Patient_LName = 'Doe', SSN = '490281739', Attn = '', Copies = 14, Microfilms = 0, Memo = '', Photocopy_Charge = 14, Retrieval_Fee = 4, Postage_Handling = 2.25, Sales_Tax = 1.8, Misc_Charges = 6.09, Bill_Hospital = 0 WHERE Invoice_ID = 1

Sorry there's so many fields! Invoice_ID, Requester_ID, and Hospital_ID are all integers, and Requester_ID and Hospital_ID are foreign keys but I know they contain valid FK values. State, Claim, Patient_FName, Patient_LNae, SSN, and Attn are text fields. Invoice_Date is a date field and Memo is a memo field. Copies and Microfilms are also integer fields. Photocopy_Charge, Retrieval_Fee, Postage_Handling, Sales_Tax, and Misc_Charges are Currency fields. Finally, Bill_Hospital is a Yes/No field.

When I run my program, at &quot;cmdResult.Execute&quot; I get the following error message:

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.

I get the same error when I add a record, but I don't get any errors when searching for a record by any field. Any help would be greatly appreciated!!
 
codeg: Have you ran this querry without the Memo field?
 
OK, I just realized that we changed the names of some of our database fields and I didn't change them in my code. Boy do I feel silly now... I fixed this error, only to get a new error, but that's another story for another time! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top