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

Select query with Parameters

Status
Not open for further replies.

fazul

Programmer
Jan 24, 2006
1
IN
Pls.
Help me how to write a Parameter query which is like:" Select * from add where city=?" i will input the value for city only at run time. Can i write it in DAO and ADO. please help me how to pass the values. I am a beginer. I am using MSAccess databse in VB6.
Thank you.
Fazulu.
Mylass@rediffmail.com
 
Fazul,

In VB, the code could look something like this:

Dim strCity as String
Dim strSQL as String

strCity = Text1.text
strSQL = "SELECT * FROM add WHERE City = '" & strCity & "'"
cnnADO.Execute strSQL 'cnnADO is your ADO connection

As City is a string, the parameter needs to be in quotes - 'City'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top