Click here to Skip to main content
14,733,542 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Im new to VB. In delphi it was simple to read a mdb file
I added an "ado query" and a table. Linked them together.
The code i used was

ado.active := false
ado.sql.text := "select * from table"
ado.active := true

It was 3 lines of code to read a database and put it into a table.

Is there no simple method like this to open a mdb file in vb?
Posted

If you look back at your delphi work it wasn't quite that simple - you had to specify the DB, and set up a connection as well.
It is the same with VB:
Using con As New SqlConnection(strConnect)
	con.Open()
	Using da As New SqlDataAdapter("SELECT * FROM myTable", con)
		Dim dt As New DataTable()
		da.Fill(dt)
		myDataGridView.DataSource = dt
	End Using
End Using
That not only fills a table, but also displays it as well...
   
You need to use ADO.NET classes to read data from access
Some useful classes r as folows
OleDbConnection
OleDbDCommand


Check this link

http://msdn.microsoft.com/en-us/library/ms971485.aspx[^]

Best of luck........
   
Hi,

For reading Access file from VB.NET code, see the following link:

http://www.startvbdotnet.com/ado/msaccess.aspx[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900