|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
hello friends,
i want to know how to connect with access using vb? thanks in advance |
|
#2
|
||||
|
||||
|
Pretty much in the same way that you do with ASP - but you just need to be more explicit when you declare stuff. Here's the basics...
Code:
Dim DBC As ADODB.Connection 'Connection to ADODB
Dim DSNtemp As String
Dim strSQL As String
Dim RS As ADODB.Recordset
Set DBC = New ADODB.Connection
Set RS = New ADODB.Recordset
DSNtemp = "Provider=MSDASQL;"
DSNtemp = DSNtemp & "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp = DSNtemp & "DBQ=C:\DataBase.mdb;"
DBC.Open DSNtemp
DBC.CursorLocation = adUseClient
strSQL = "SELECT ExampleField FROM tblExample;"
RS.Open strSQL, DBC, 2, 3
If RS.EOF = False Then
msgbox RS("ExampleField ")
Else
msgbox "Nothing There!"
End If
__________________
LozWare Website Directory Whooo! Free submissions, no recip needed. I'm a nice guy
|
|
#3
|
|||
|
|||
|
You should use the newer Jet OLEDB database drivers, you can find examples at www.able-consulting.com
The MSDASQL driver is, I think, being phased out by MS, and using the older ODBC drivers is more prone to problems. Also you need to add a reference in your VB project to ADO. VB6 has a whole lot of databound controls, you can do all the database connections using controls rather than code if you prefer. Refer to the VB documentation.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#4
|
||||
|
||||
|
I agreed with the first 2 things you said Doug - but not the third! The controls SUCK! Its a lot better to use the code - so much more adaptable.
|
|
#5
|
|||
|
|||
|
Quote:
Everyone is entitled to an opinion, right or wrong. |
|
#6
|
|||
|
|||
|
thank you for sending me code.
its working. thanks again |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > How i can connect access with vb? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|