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 = "DSN=myDSN"
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 "cmdResult.Execute" 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!!
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 = "DSN=myDSN"
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 "cmdResult.Execute" 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!!