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 = "Delete From 資料表1 Where 識別碼=" & deletenumber.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) 人氣()