|
| Connecting to an Access Database from VB.net |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.general.
| Eric Lommatsch |
| GOOD ANSWER |
Help. I am trying to find a way to be able to create a windows application in VB.net? I want to be able to connect to a local Access Database. I have found a walkthrough that describes Connecting to a SQL server DB. I tried to follow this and see if I could figure out how to connect to an access database by making modifications. But as far I can see there no place where I can make this connection. Can anyone point me in the directions of something that might describe how to connect to an access database from VB.net?
|
|
|
| |
|
|
| |
| |
| PieterBaaS |
| GOOD ANSWER |
Eric, Although I am a amateur-programmer I just had the same problem and have some suggestions for you for using VB.NET and Microsoft Access: 1. Use ADO.NET and you get a disconnected/intermittent access to your local Access database. Looks good for small databases, remote access and binding to controls. I donot see how to use Seek or big databases that do not fit in memory. I read advices to go to use SQL Server.... which has the future. 2. Use DAO, but you have to create a link between your managed (VB.NET) code and the unmanaged (old) DAO dll. With VS.NET it is rather easy: -in VS.NET in your project make a reference to DAO (Project=>Add Reference=>COM=>Microsoft DAO 3.6 Object Library = dao360.dll) -VS.NET makes an "Interop.DAO.dll" for you as a bridge between managed/unmanaged code (donot worry it is all "transparant") You can use the Object Browser to see the Interfaces etc. It works a bit different form VBA and VB. For instance a "DAO.Workspace" is now an interface instead of a Class, and the Intellisense looses some of its Intelligence. -now this code works for me: Imports System.Runtime.InteropServices (Public Class etc..) Dim dbE As DAO.DBEngine Dim db As DAO.Database Dim rs As DAO.Recordset Dim strCon As String Dim x, y As Integer
dbE = New DAO.DBEngine() strCon = "Northwind.mdb" db = dbE.OpenDatabase(strCon) rs = db.OpenRecordset("Products") rs.Index = "ProductName" rs.MoveFirst() For x = 0 To 5 For y = 0 To 5 Console.Write(rs.Fields(y).Value) Next Console.WriteLine() rs.MoveNext() Next rs.Close() db.Close() Good luck! Pieter
On Fri, 26 Apr 2002 12:11:27 -0700, "Eric Lommatsch" <Click here to reveal e-mail address> wrote:
[Original message clipped]
|
|
|
| |
|
|
| |
|
| |
| Scott Hutchinson |
| GOOD ANSWER |
To connect to an Access database, follow the examples for SQL Server, except substitute the OleDb namespace for the SqlClient namespace in System.Data. The object models are nearly identical.
Use the Jet OLE DB provider in the connection string.
Scott Hutchinson Click here to reveal e-mail address
"Eric Lommatsch" <Click here to reveal e-mail address> wrote in message news:29bf01c1ed56$2a28eca0$9ae62ecf@tkmsftngxa02... [Original message clipped]
|
|
|
| |
|
|
| |
|
| |
| Peter Chong |
"Eric Lommatsch" <Click here to reveal e-mail address> wrote in message news:<29bf01c1ed56$2a28eca0$9ae62ecf@tkmsftngxa02>... [Original message clipped]
Hi, Eric check www.exmlsoft.com The ASP.NET wizard(beta) will create not only connection, but also code for simple add,delete and update form and dynamic query form.
|
|
|
| |
|
| |
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|