-
Searching for a string in a table in a database...
Hi, Basically, Im making a little program to sort out my music collection. However, I have put in a MSflex grid and added the database and you can add entries etc which is all working fine. However, I was wondering if it is possible to search by Artist name etc a string in a table of the database? So basically i want to be able to search for an artist in my music collection?
Is this possible and if so pleqase oculd someone show me how t do it...
Thanks alot,
Jenks
-
Please read http://www.officecomputertraining.co...ges/page37.asp . The SQL statement to search your database by artist name will be something like, "SELECT * FROM TableName WHERE ArtistName = 'Bob Dylan'".
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
:(
i can't seem to get it to work..is there any chance anyone could post some example code up here?
-
which database are you using? Phil's suggestion should work with any database, but you have to replace TableName and ArtistName with the names you have used in your database. Post the code you wrote so far.
Marco
"There are two ways to write error-free programs. Only the third one works."
Unknown
-
Private Sub Form_Load()
'the format string just lets you define a format for how
'your flexgrid will appear
MSFlexGrid1.FormatString = "Title |" & _
"Artist | Genre"
'make sure the search path to the db is always in the right spot
Data1.DatabaseName = App.Path & "\CDCollection.mdb"
'set up the recordsource for the datasource and flexgrid control
'in this case, it's just a raw SQL query, simple simple.
Data1.RecordSource = "select * from CDs order by Title"
that is my code that open up the database into a MSFlexgrid.
then I wanna add a button and a text.text to search the database by title and then like just highlight or in some way show up the search results...
I tried something like was said earlier but couldnt get it to work
any help will be much appriacheted.
Jenks
-
data1.Recordsource = "select * from CDs where XXXXX = '" + text1.text + "'"
replace XXXX with the name of the record field you use to store the name of the artist in the database
Marco
"There are two ways to write error-free programs. Only the third one works."
Unknown
-
You may also have to Refresh the data control after changing the RecordSource.
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|