Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Searching a record in VB linked with Database

Author  Topic 

david2010
Starting Member

7 Posts

Posted - 2010-03-08 : 10:04:08
Hi everyone,

Its a bit of a VB/DATABASE query question.

I am creating an application in vb linked with a access database and i am having problems searching records.

For the team screen I have the following database query that I wish to call:


SELECT     TeamName, [Section]FROM  Team
WHERE (TeamName LIKE ''' & TeamNameSearchTextbox.Text & ''')


The whole point is the user would enter a team name or part of a team name in the TeamNameSearchTextbox field and click search and the database would return the matching records. However at the minute when search is clicked nothing is returned.

Here is the button click event code i have:


TryTeamTableAdapter.SearchTeamName(Me.DefectManagementToolDatabaseDataSet.Team)Catch ex As ExceptionMsgBox("Invalid")End TryTry
TeamTableAdapter.SearchTeamName(Me.DefectManagementToolDatabaseDataSet.Team)
Catch ex As Exception
MsgBox("Invalid")
End Try


SearchTeamName is the name of the database query.

Was wondering if anyone could help i have been trying to solve this problem for quite a while now.

Many thanks,

David

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-03-08 : 10:09:09


SELECT TeamName, [Section]FROM Team
WHERE (TeamName LIKE ''%' & TeamNameSearchTextbox.Text & '%'')


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

david2010
Starting Member

7 Posts

Posted - 2010-03-08 : 10:11:55
I believe if you use access you have to use * instead of % don't you??

I am sure I have tried this before, this might mean there must be something wrong in the way i am calling it on the search button click event.

Any ideas??
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-03-09 : 00:56:18
Yes. If it is ACCESS use * instead of %

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -