Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB 2005 and searching a MS database

Status
Not open for further replies.

jcdemon2007

Technical User
Apr 30, 2007
4
US
What I'm looking for is a few pointers. I need to search a datagrid by using user input. So heres my problem I'm not sure on how to do a sql statment that will use text box for the input. I have done this in Visual Basic 6, but I need to move on to VB.net. Please help with any input you may have. Thanks
 
If it is a datagrid, there must be a property called somehow like RowFilter. Then you can do:
- datagrid1.Rowfilter="name='" & txtname.text & "'"

If it is a query and then show the results to a datagrid, the query show have WHERE clause, possibly AND, OR keywords.. and so on:
- "SELECT ... FROM ... WHERE ..."

The query is a string. You can join strings as i did above. For a query it is better that you either did:
1. have parameters, or
2. format the string (.. WHERE [name]='{0}')


Hope these help
 
I'm using the datagridview control in VB 2005. I do not see a Rowfilter. I'm very new to the VB 2005. I have used VB6 for years but would like to move on to VB 2005. I know I'm just missing something small.
 
I'm assuming you're using a .mdb dBase and have an AccessDataSource control on the form that functions as a DataSet.

Try something like this:

AccessDataSource.SelectCommand = "SELECT * FROM TableName WHERE ColumnName = @ColumnName"

AccessDataSource.SelectParameters.Add(New Parameter("@ColumnName", TypeCode.String, txtFindIt.Text))
 
Ok, Here's what I have. I have a DataSet, BindingSource and the datagrid view on the form. These are all .net 2.0 controls. I'm using VS 2005 Pro. I know this has to be something simple. It just seems like MS change way to mutch from VB6. Any help or pointer would be great. I'm just not finding what I need. Please help, anyone.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top