473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Query database in VB.NET

I would like to create a query to run in a VB.NET application that searches
an Access contacts database for 1 or more strings, e.g. FirstName, LastName
etc. and returns the results in a DataGrid.

Can this be done and if so can anyone offer me any assistance?

Thanks
Nov 21 '05 #1
2 1249
"gregas" <gr****@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
I would like to create a query to run in a VB.NET application that searches
an Access contacts database for 1 or more strings, e.g. FirstName,
LastName
etc. and returns the results in a DataGrid.

Can this be done and if so can anyone offer me any assistance?

Thanks


Yes, it can be done. You might start by checking out the System.Data.OleDb
namespace in MSDN Online. A handy resource for learning how to use the
Connection, DataAdapter, DataSet, etc., is to use the Data Form Wizard and
look at the form and code it creates.
Nov 21 '05 #2
On Wed, 23 Mar 2005 15:15:03 -0800, gregas <gr****@discussions.microsoft.com> wrote:

¤ I would like to create a query to run in a VB.NET application that searches
¤ an Access contacts database for 1 or more strings, e.g. FirstName, LastName
¤ etc. and returns the results in a DataGrid.
¤
¤ Can this be done and if so can anyone offer me any assistance?

Rather simple example should get you started:

Dim ConnectionString As String

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\db1.mdb"
Dim AccessConnection As New System.Data.OleDb.OleDbConnection(ConnectionString )
AccessConnection.Open()

Dim da As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM Contacts WHERE...(add your
criteria here) ", AccessConnection)

Dim ds As New DataSet

da.Fill(ds, "Contacts")

DataGrid1.SetDataBinding(ds, "Contacts")

AccessConnection.Close()
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: jaysonsch | last post by:
Hello! I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the...
3
by: Nick Truscott | last post by:
<? // scoreinput.php - input a match score when match selected from list ?> <html> <head> <basefont face="Verdana"> </head> <body>
15
by: Rolan | last post by:
There must be a way to enhance the performance of a query, or find a plausible workaround, but I seem to be hitting a wall. I have tried a few tweaks, however, there has been no improvement. ...
7
by: Bernard Lebel | last post by:
Hello, I'm stumbled at a serious problem, and quite frankly getting desparate. This is a rather long-winded one so I'll try to get straight to the point. I have this Python program, that...
13
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything...
1
by: Pradeep83 | last post by:
Hi All Problem : I am unable to retrieve the data from the table in postgres database using C application which i have written in solaris os. Query: How to check whether connection is there...
2
by: Bob Alston | last post by:
If you have an access form with record source being a straightforward query and where clause in the form definition, will the query be sent to the back end jet/Access database and executed there,...
3
by: mnjkahn via AccessMonster.com | last post by:
I'm running Access 2003, modifying a query that has over 45 fields. When I right click on the field name in Query Design View, and then click Build, Access crashes before the Build window...
32
by: wexx | last post by:
I have been looking for some time now (reading books off Safari, searching through forums,etc) I have found no solution to this problem. I turn to anyone of you that may be able to help me. I'm...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.