|
-
Jan 18th, 2000, 10:07 PM
#1
Thread Starter
Member
Can any help me out with an example how to display a select text from text box, and display the result to a grid with a sql query. I can easier do this in MS-Access, but find it differcult with VB ADO.
Thanks..
-
Jan 19th, 2000, 01:53 PM
#2
Guru
http://www.vb-world.net/ubb/Forum3/HTML/002669.html
This post uses SQL server, just change the connection string to your Access DB and the rest should work fine
Tom
[This message has been edited by Clunietp (edited 01-20-2000).]
-
Jan 19th, 2000, 10:30 PM
#3
Thread Starter
Member
Clunietp,
Thanks for the help, I got it to connect and display the data in to the grid with the whole data. However I want to customer my Sql statement to display only the select data, I got and error, here is my code:
Set cn = New Connection
cn.Open "provider=Microsoft.jet.OLEDB.4.0;" & "Persist Security Info=FALSE;" & "Data Source = C:\12_13_99.mdb"
rs.Open "SELECT TestTable.* From TestTable where "combo1.Text" = "text1.Text" order BY LATA, `LERG 6_NPA`, `lerg 6_nxx`"
End Sub
Combo1.text is select from combo list
text1.text is text from text box.
Did I code it right or I missed something?
Thanks.
-
Jan 19th, 2000, 11:35 PM
#4
Guru
change this:
SELECT TestTable.* From TestTable where "combo1.Text" = "text1.Text" order BY
to this:
SELECT TestTable.* From TestTable where MyFieldNameToSearch = '" & text1.Text & "' order BY...
Tom
-
Jan 20th, 2000, 11:31 AM
#5
-
Jan 20th, 2000, 12:11 PM
#6
Thread Starter
Member
Clunietp,
Is there anyway we can pass the field from combo1 list to MyFieldNameToSearch.
ex. instead of
SELECT TestTable.* From TestTable where MyFieldNameToSearch = '" & text1.Text & "' order BY..
MyfieldNameToSearch is pass on by combo text?
Just wondering...
-
Jan 20th, 2000, 12:27 PM
#7
Guru
You can concatenate any string you would like.
SELECT TestTable.* From TestTable where [" & combo1.text & "] = '" & text1.Text & "' order BY...
I added the brackets [] in case your table name had spaces in it....
Tom
-
Jan 20th, 2000, 12:38 PM
#8
Thread Starter
Member
Clunietp,
thank for all you help. Don't know what to do without. Once again...mucho garcias!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|