|
|
|
|
|
|
Har du set hvor smart det kan være?
|
|
SmartOffice - ADO_AccessData
Hent data fra en Access database.
Eksempel 1
Option Explicit
' Reference to: Microsoft ActiveX Data Objects x.x Library
Public Const gsDB_PROVIDER As String = "Microsoft.jet.oledb.4.0"
'Public Const gsDB_ID As String = ""
'Public Const gsDB_PWD As String = ""
Public Const gsDB_DBQ As String = "C:\Kunder.mdb"
Public gconDB As ADODB.Connection
Public grsData As ADODB.Recordset
Public Sub ConnectAccessDB(ByVal bConnect As Boolean)
If bConnect Then
Set gconDB = New ADODB.Connection
gconDB.Provider = gsDB_PROVIDER
gconDB.Open gsDB_DBQ
Else
grsData.Close
gconDB.Close
Set grsData = Nothing
Set gconDB = Nothing
End If
End Sub
Public Function FillRecordSet(ByVal SQLSentence As String) As Boolean
FillRecordSet = False
Set grsData = New ADODB.Recordset
On Error Resume Next
Set grsData = gconDB.Execute(SQLSentence)
If Not grsData.EOF Then FillRecordSet = True
End Function
Test 1
Public Sub UseDataInRecordSet()
ConnectAccessDB True
If FillRecordSet("select * from kunder") Then
' If FillRecordSet = True then there is Data in grsData
' Now do what you need to do with the RecordSet
MsgBox grsData.Fields(1).Value
End If
ConnectAccessDB False
End Sub
|
|
|
|
Smart Data Management
Compare 2 Columns
Excel Super- Subscript
Teachers Excel Tools
|
|
|
|
|
|