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 = "Update 資料表1 set 處理情況 = '未處理'Where 識別碼 =90" ' 為何不要''????

'上面這行是範例 90不需要'90'


Dim str1 As String = "Update 資料表1 set 處理情況 = '" + TextBox3.Text + "'" + " Where 識別碼 =" + deletenumber.Text + ""

'請注意 deletenumber.Text 不需要變成 'deletenumber.Text' 就可以修改囉  這邊卡超久


Dim cmd As OleDbCommand = New OleDbCommand(str1, conn)

'執行資料庫指令OleDbCommand

cmd.ExecuteNonQuery()

'這兩行也是必要的
'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

 

'最後資料表要更新 用FORM那個語法更新像是 Me.資料表1TableAdapter.Fill(Me.SqlDataSet.資料表1)

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