Discussion Locked

ODBC creation thro..

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello ,
please send me any programe in visual basic 6.0 for odbc creation which is connect to preexising access database.

please..... tell me fast..(Programe must in visual basic)

1 reply

by jay eckles

Honestly...how hard is it to do a search on "Visual Basic ODBC Access example"?
Anyway, here you go, straight from the source:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q166392
This is called a DSN-less connection. There are a couple of other ways to connect to an ODBC data source. Also, know that if you don't like this example, there are a lot of ASP examples written in VBScript which for the most part you can copy and paste into Visual Basic source with little or no translation.

Private Sub Command1_Click()
Dim Cn As New rdoConnection 'creatable rdoConnection
Dim Qr As New rdoQuery 'creatable rdoQuery
Dim Rs As rdoResultset 'pointer to rdoResultset
Dim cnstr As String 'hold connection info

cnstr = "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=c:\program files\devstudio\vb\biblio.mdb;" & _
"Uid=Admin; Pwd="
Cn.Connect = cnstr Cn.CursorDriver = rdUseClientBatch
Cn.EstablishConnection Prompt:=rdDriverNoPrompt
Set Qr.ActiveConnection = Cn
Qr.SQL = "Select * From Authors"
Set Rs = Qr.OpenResultset(Type:=rdOpenKeyset, _
LockType:=rdConcurBatch)
Debug.Print Rs(0), Rs(1), Rs(2)
End Sub

This discussion is closed to new replies.