Am working on a project using vb.net and i have connected a database to it. I have an employee table within that and now i want to create a search box in vb.net where by if i type the employee-number of the employee i can get access to his or her details.

Can anyone help me out...

Recommended Answers

All 17 Replies

Please show what you have done so far.

When you say you connected the Database please elaborate.

What Method have you applied. How good is your SQL?

Hi

You should do something like this:

sub EmployeeSearch 

dim  EmployNo as integer
dim mySQL as string

EmployNo = cint(MyTextbox.text)
mySQL =  "SELECT * FROM tblEmployee WHERE (EmployeeNo =" &EmployNo &")"
'run query on db and get result.

Please show what you have done so far.

When you say you connected the Database please elaborate.

What Method have you applied. How good is your SQL?

I have used ms.access not sql

Hi
The SQL is basically the same...

Provide more details on where exactly you are stuck and we'll see what we can do..

hey im also having this similar problem.
Using Ms Access.
I have a table containing names and numbers and i have created the cmd button for search but kind of miss the coding.
I have a connection in my data enviroment and everything else is good except 4 this

Any help would be appreciated..
fourty.

Hi Guys,

Look up any of the following in Google or similar:

ADO.NET DataReader
ADO.NET DataAdapter
ADO.NET Command

Pay attention to the examples given...

Also use the Access QBE to design your SELECT Query and switch to SQL view to get the Query in Access compatible SQL.

With out more specifics i.e. code that's the best help I can give you.

you can use like key word to accomplish this

you can use like key word to accomplish this

How could i accomplish that

have ideat how to do in sql server if you want will show you

SELECT * FROM tblEmployee WHERE EmployeeNo LIKE " % EmployNo %"

simple method to search and there is another stratagy like fulltextsearch if you want you can use it also


and if u done with problem so please mark as solved so that no other one will use there affort for that question

have ideat how to do in sql server if you want will show you

I am using ms.access u got any clues on that

sorry dont know now and realy ddont have time to do RND now you try if i will get time will provide solution ok sorry again

try the given query think will work for you

got solution Replace % th * in access Wild card is * try after replacing will work definightly ko bye god bless u

SELECT * FROM tblEmployee WHERE EmployeeNo LIKE " * EmployNo *"

This is serious
No one seems to tell us the exact thing
I have coded the following but when i keyin a wrong serviuce no., the search box nolonger accepts even the true entries and all the fields go blank

You might wanna try this jolly if it will work for you. You only need to edit in between the lines..

Here my code:
Private Sub cmdSearch_Click()
Dim Mloop As Integer
Dim found As String
'Input service Number to search
Mloop = 0
found = InputBox("Enter Service Number", "Search")
If found = "" Then
Exit Sub
End If
DataEnvironment1.rsdepartments.MoveFirst 'Move the pointer to the first record
Do While Mloop = 0
If txtLno = found Then 'if search found display an alert message
MsgBox "Record found"
Exit Sub
End If
If DataEnvironment1.rsdepartments.EOF Then 'if search not found display an error message
MsgBox "Enter a VALID Service Number", vbCritical, "Find"
Dataenviroment1.Recordset.Requery
Exit Sub
End If
DataEnvironment1.rsdepartments.MoveNext
Loop
End Sub.

Please any reply
fourty

Thank You so much...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.