Question

I am trying to do a simple select in a access 2007 DB as:

sqlSelect = "select * from Datos_De_Quejas where Ape_Pax = " & textape.Text & " " 
RS.Open sqlSelect, cnn, adOpenStatic, adLockOptimistic

The table is called Datos_De_Quejas, the column Ape_Pax and cnn is the connection.

I checked the spelling 100 times and it looks correct, but it gives me the following error.

No value given for One or more required parameters

The following select is working perfectly fine in the same procedure:

sqlSelect = "select * from Datos_De_Quejas where ID = " & textnro.Text & " "
RS.Open sqlSelect, cnn, adOpenStatic, adLockOptimistic

I cannot see what I am doing wrong. Thank you!

Was it helpful?

Solution

I'm going to guess that ID is an integer field, while Ape_Pax is a varchar.

try:

 "select * from Datos_De_Quejas where Ape_Pax = '" & textape.Text & "' " 

with the single quotes.

Also, building an SQL statement like that -- particularly when used with text from a user input field -- is an extremely bad idea. Use a parameterized query ( "select * from Datos_De_Quejas where Ape_Pax = ?") and pass the Text as a parameter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top