i have just installed visual studio 10. Im not familiar with it. I want to connect MDB file to it. I have googled that but could not find appropriate code. So would anyone help me finding the equivalent Visual Studio 10 code to the VB6 code i am pastng below.
Thanks in advance!

Private cn As ADODB.Connection
Private rs As ADODB.Recordset

Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Test.mdb;Persist Security Info=false"
cn.Open
Set rs = New ADODB.Recordset
rs.Open "Sample", cn, adOpenKeyset, adLockPessimistic, adCmdTable

rs.MoveFirst
Dim FirstName As String
FirstName = rs.Fields("fname")

rs.Close
cn.close

I have a post here that shows using ADODB. It is on page 1. See "Version 4 (using ADODB and OleDbDataAdapter)" It is for DB2 Express, but just change the connection string and it should work.

For additional connection strings see:
Connection Strings

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.