Click here to Skip to main content
15,886,851 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB.NET
CmpCommand = New OleDbCommand("Select * FROM tblCompetitie WHERE((verID)=myVerID) ORDER BY comOmsch", BiljartConnection)
CmpCommand.Parameters.Add(MyVerID)
CmpAdapter = New OleDbDataAdapter
CmpAdapter.SelectCommand = CmpCommand
CmpTable = New DataTable()
CmpAdapter.Fill(CmpTable)

Now I get the error: The OleDbParameterCollection only accepts objects of type OleDbParameter which are not-null and no objects of Int64.'

VerID and myVerID are long integers
myVerId is a saved primary key of a related table and verID = the Foreign key in the current table. I only want the records with the FK equal to the saved PK.

What I have tried:

I tryed several other defnitions of the where clause (with or without parenthesis, ect.)
All the examples are for C# and not for VB
Posted
Updated 18-Sep-21 6:47am
v4
Comments
Richard MacCutchan 18-Sep-21 6:42am    
You forgot to add the parameter values (myVerID and comOmsch) to the CmpCommand object.
Daan Assenberg 18-Sep-21 7:42am    
How do you mean? myVerid and VerID contain values to my opinion.
Richard MacCutchan 18-Sep-21 7:51am    
Yes but you have merely added those names inside the SQL command, not the values.
Daan Assenberg 18-Sep-21 10:43am    
To me it is not clear how to specify parameters in the right way. I have little experience with databases in VB and the examples are in C#.
Richard MacCutchan 18-Sep-21 11:56am    
Then use the dropdown at the top of the page to switch the sample code to VB. You will benefit greatly if you make regular use of the MSDN documentation.

See OleDbCommand.Parameters Property (System.Data.OleDb) | Microsoft Docs[^] for the correct way to add property values to an OleDbCommand.
 
Share this answer
 
VB
CmpCommand.Parameters.Add(MyVerID)

You cannot add a number as a parameter, you must tell the system, which parameter you are referring to, what type it is and what its value is. See OleDbParameter Class (System.Data.OleDb) | Microsoft Docs[^] for a simple example.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900