By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,967 Members | 1,710 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,967 IT Pros & Developers. It's quick & easy.

search records in mdb using vb

P: 4
please help... i have a vb program which needs to search for employee name inside empmas.mdb, specifically empmas table. the user will input the idnumber on a textbox and from that it will search the name of the employee and display it in a label in my vb program.

all i have is this:


Dim db As Database

Dim rs As Recordset

Dim SQLString As String

Set db = OpenDatabase("C:\empmas.mdb")
Sep 14 '07 #1
Share this Question
Share on Google+
3 Replies


debasisdas
Expert 5K+
P: 8,127
Try to search using SQL query .

Frame the query dynamically on user input
Sep 14 '07 #2

P: 4
i'm sorry but i don't know how... i haven't used sql... i'm only a beginner in programming... i've read about SELECT in sql but i haven't understood the concept...

i tried this:
strSQLString = SELECT * FROM empmas WHERE e_empno like '*" & txtEmpNum.text & "*'";
Sep 14 '07 #3

jamesd0142
100+
P: 469
please help... i have a vb program which needs to search for employee name inside empmas.mdb, specifically empmas table. the user will input the idnumber on a textbox and from that it will search the name of the employee and display it in a label in my vb program.

all i have is this:


Dim db As Database

Dim rs As Recordset

Dim SQLString As String

Set db = OpenDatabase("C:\empmas.mdb")
-------------------
Hi m8, im new to vb myslef but i have managed to successfully do something simular to this.

Dim Cmd2 As OleDb.OleDbCommand
Dim Con2 As OleDb.OleDbConnection
Dim Sql2 As String = Nothing
Dim Reader2 As OleDb.OleDbDataReader
Dim ComboRow2 As Integer = -1
Dim Columns2 As Integer = 0
Dim Category2 As String = Nothing


Con2 = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OleD b.4.0;data source=FAQs.mdb")
Sql2 = "SELECT Question FROM tblQuestion " & _
"WHERE Category_Id = '" & strChosenQuestion & "'"
Cmd2 = New OleDb.OleDbCommand(Sql2, Con2)
Con2.Open()

Reader2 = Cmd2.ExecuteReader()
While Reader2.Read()
For Columns2 = 0 To Reader2.FieldCount - 1
Category2 = Reader2.Item(Columns2) 'READ COLUMN FROM DATABASE
Next
cboQuestion.Items.Add(Category2)
ComboRow2 += 1
End While
Con2.Close()

c if this helps...
Sep 14 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.