Dim str As String = "Provider=Microsoft.Jet.Oledb.4.0;Data source=bad.mdb"
Dim conn As OleDbConnection = New OleDbConnection(str)
' TODO: Modify the connection string and include any
' additional required properties for your database.
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source= C:\Users\user\Desktop\台大比賽\sql.mdb"
Try
conn.Open()
'查詢資料.
Dim str1 As String = "Insert Into 資料表1(時間,車牌,汽車位置,成員人數,撞擊位置,處理情況)Values ('" & time.Text & "','" & carnumber.Text & "','" & NEPS.Text & "','" & people_count.Text & "','" & striketo.Text & "','" & "未處理" & "')"

 


Dim adp1 As OleDbDataAdapter = New OleDbDataAdapter(str1, conn)
'將查詢結果放到記憶體set1上的"1a "表格內
Dim set1 As DataSet = New DataSet
adp1.Fill(set1, "1a")
'將記憶體的資料集合存放到視窗畫面上的DataGrid上
' 資料表1DataGridView.DataSource = set1.Tables("1a")


Catch ex As Exception
MessageBox.Show("Failed to connect to data source")
Finally
conn.Close()
End Try


Me.資料表1TableAdapter.Fill(Me.SqlDataSet.資料表1)

阿倫 發表在 痞客邦 PIXNET 留言(0) 人氣()