If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > Visual basic Run-time error '3061' Too few parameters, Expected 1

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Aug 2003
Location: Belgium
Posts: 5
Visual basic Run-time error '3061' Too few parameters, Expected 1

Can somebody help me, when I want to run my project and I select a customer and a product I get this message. Run-time error '3061' Too few parameters, Expected 1.

It's in the first sentence I get the error, in "Set ProductRs = EricDb.OpenRecordset(strSQL, dbOpenDynaset)"


Set ProductRs = EricDb.OpenRecordset(strSQL, dbOpenDynaset)

ProductRs.Index = "PrimaryKey"

'Zoek Product
ProductRs.Seek "=", cmbProducts.ItemData(cmbProducts.ListIndex)

'product gevonden
'laat product details zien
If Not ProductRs.NoMatch Then


LblPrice.Caption = ProductRs!Artprijs
LblAmount.Caption = ProductRs!Amount
End If


End Sub


I know it's something with my sql but I have no clue what can be the problem.

How can I solve this problem ?
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Jul 2003
Location: London
Posts: 5
This is an error because you have some invalid SQL. Without seeing this, it is impossible to say but the most common problem is if you have referenced a field that does not exist in the database.

SELECT customet, customer_id FROM customers

In the above example I am trying to get the "customer" and "customer_id" fields from the "customers" table. I get an error 3061 because I have misspelt customer.
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Aug 2003
Location: Belgium
Posts: 5
but how can i find the problem then ?

SELECT
FROM Region INNER JOIN (Amount INNER JOIN (BTWPercentage INNER JOIN (Product INNER JOIN (Customer INNER JOIN ID ON Customer.KlantID = ID.KlantID) ON Product.ArtikelID = ID.ArtikelID) ON BTWPercentage.BTWID = Product.BTWID) ON Amount.EenheidID = Product.EenheidID) ON Region.GemeenteID = Customer.GemeenteID;


this is the sql
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Jul 2003
Location: London
Posts: 5
I created a database in Access with the following tables and your SQL worked fine. I think that one of these fields does not exist in the database you will need to check the database.


Amount.EenheidID

BTWPercentage.BTWID

Customer.KlantID
Customer.GemeenteID

ID.ArtikelID
ID.KlantID

Product.EenheidID
Product.BTWID
Product.ArtikelID

Region.GemeenteID


(I have used * to get all fields)

SELECT * FROM Region INNER JOIN (Amount INNER JOIN (BTWPercentage INNER JOIN (Product INNER JOIN (Customer INNER JOIN ID ON Customer.KlantID = ID.KlantID) ON Product.ArtikelID = ID.ArtikelID) ON BTWPercentage.BTWID = Product.BTWID) ON Amount.EenheidID = Product.EenheidID) ON Region.GemeenteID = Customer.GemeenteID


If you have checked and all are in the database then try:

Depending on the database you are using and how you are connecting to it, you may be using a reserved word. Try putting square brackets around field and table names (e.g [Amount] and [Amount].[EenheidID])
Attached Files
File Type: zip test.zip (9.4 KB, 213 views)
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
Join Date: Aug 2003
Location: Belgium
Posts: 5
This is weird, I searched but I don't find the problem.

I will include the program in a zip file so that you can look at it because I don't find the problem.
Attached Files
File Type: zip visual basic prog.zip (81.6 KB, 248 views)
Reply With Quote
  #6 (permalink)  
Old
Registered User
 
Join Date: Jul 2003
Location: London
Posts: 5
The problem was with:

Product.BTWID = BTWPercentage.BTW

should be:

Product.BTWID = BTWPercentage.BTWID

Also, need to remove single quotes here as ArtikelID is not a text field:

Product.ArtikelID = '" & cmbProducts.ItemData(cmbProducts.ListIndex) & "'

Also, you will need to use Findfirst rather than Seek because Seek won't work with a dynaset. (See Attached)
Attached Files
File Type: zip form12.zip (2.7 KB, 215 views)
Reply With Quote
  #7 (permalink)  
Old
Registered User
 
Join Date: Aug 2003
Location: Belgium
Posts: 5
First thank you for helping me with this. But I have a second question. Why is it not standing in the data grid so that I can print it on a paper ?


Best Regards
Reply With Quote
  #8 (permalink)  
Old
Registered User
 
Join Date: Jul 2003
Location: London
Posts: 5
I have never used datagrid before but I would assume that it is supposed to be used with a datacontrol. You have not used any datacontrols in your project and I would suggest that you do not use them because they are not as flexible as using code like you have done so far.
You will need to see if you can add items into the datagrid control manually by finding some documentation for it. If not then you may have to use a different type of grid. I use an old grid called Apex TDBGrid which I got from the internet. It is good because you can link it to data controls and also add items in manually. This control is years old and there is probably much better stuff out there now.
You may even have some already on your pc. Go to Project > Components in vb and see if there are any grid controls on your system.

You could even use the Listview control to show items. This can be found by enabling the "Microsoft Windows Common Controls 6.0" from components screen in vb. You can set the View property to "report" which makes the list look like a grid (without the lines). You will then need to learn about using this control.

Happy coding...
Reply With Quote
  #9 (permalink)  
Old
Registered User
 
Join Date: Aug 2003
Location: Belgium
Posts: 5
OK, thanks for helping me
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On