Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim fn As String
Dim count As Integer
CommonDialog1.ShowOpen
fn = CommonDialog1.FileName
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
With conn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & fn
.Mode = adModeReadWrite
.CursorLocation = adUseClient
.Open
End With
Set rs = conn.OpenSchema(adSchemaTables)
count = 0
While Not rs.EOF
count = count + 1
If rs.Fields("TABLE_TYPE") = "VIEW" Then
'Combo1.AddItem rs.Fields("TABLE_NAME"), count
MsgBox rs!TABLE_NAME
End If
rs.MoveNext
Wend
While Not rs.EOF
'If rs!TABLE_TYPE = VIEW Then
Combo1.AddItem (rs!TABLE_NAME)
Debug.Print rs!TABLE_NAME
'End If
rs.MoveNext
alibek писал(а):Так ты не VIEW ищи, а TABLE.
While Not rs.EOF
If rs!TABLE_TYPE = "TABLE" Then
Combo1.AddItem (rs!TABLE_NAME)
Debug.Print rs!TABLE_NAME
End If
rs.MoveNext
Dim fn As String
Dim conn As Adodb.Connection
Dim rs As Adodb.Recordset
'************************************************************************
Private Sub closeDB()
conn.Close
End Sub
Private Sub openDB()
Set conn = New Adodb.Connection
Set rs = New Adodb.Recordset
With conn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & fn
.Mode = adModeReadWrite
.CursorLocation = adUseClient
.Open
End With
Set rs = conn.OpenSchema(adSchemaTables)
While Not rs.EOF
If rs!TABLE_TYPE = "TABLE" Then
Combo1.AddItem (rs!TABLE_NAME)
'Debug.Print rs!TABLE_NAME
End If
rs.MoveNext
Wend
End Sub
'************************************************************************************
Private Sub Command1_Click()
CommonDialog1.ShowOpen
fn = CommonDialog1.FileName
openDB
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
closeDB
conn.Open
With rs
.ActiveConnection = conn
.Source = Combo1.Text
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open , , , , adCmdTableDirect
End With
'MsgBox Combo1.Text & "asd"
Set TDBGrid1.DataSource = rs
Else
On Error Resume Next
End If
End Sub
Mario писал(а):А кто нибудь знает можно ли таблицу заполнить данными без использования datacontrol'a?
alibek писал(а):OpenSchema.
А ADODC лучше выкинь.
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 114