1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
| Imports System.Data
Imports System.Data.OleDb
Dim str As String
Dim conn As New OleDbConnection
Dim ds As New DataTable
Dim adp As New OleDbDataAdapter
Dim cmd As New OleDbCommand
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\DataBase.mdb;Jet OLEDB:Database Password=8AFE2B7801749F02C649"
conn = New OleDbConnection(str) '創建連線物件
Try
conn.Open() '打開連接
'MessageBox.Show("已經正確建立連接!", "連接正確")
Catch ex As Exception
MessageBox.Show(ex.Message, "連接錯誤")
Exit Sub
End Try
adp = New OleDbDataAdapter("select * from Record", conn)
adp.Fill(ds)
ShowDataInLvw(ds, ListView1)
'MsgBox(ds.Rows(0).Item(0).ToString)
'MsgBox(ds.Rows(0).Item("VecesError").ToString)
DataGridView1.DataSource = ds
conn.Close()
End Sub
|
沒有留言:
張貼留言