我有一個使用MySQL
數據庫的vb.net程序。現在我將數據庫更改爲Microsoft Access 2010
。我變了樣連接優先所有必要的設置,命令等OleDb數據讀取器問題
的問題是:我有一個錯誤周圍
mydata = mycommand.ExecuteReader
,併產生一個錯誤:
Error 1 Value of type 'System.Data.OleDb.OleDbDataReader' cannot be converted to 'MySql.Data.MySqlClient.OleDb.OleDbDataReader'
整個代碼:
Public Sub showAlarm()
Try
Dim conn As New OleDb.OleDbConnection(connection)
Dim myadapter As New OleDb.OleDbDataAdapter
conn.Open()
Dim sqlquery = "select * from alarm"
Dim mycommand As New OleDb.OleDbCommand
mycommand.Connection = conn
mycommand.CommandText = sqlquery
myadapter.SelectCommand = mycommand
Dim mydata As MySqlDataReader
mydata = mycommand.ExecuteReader
'If mydata.HasRows = 0 Then
' MsgBox("Data Not Found")
' TextBox1.Clear()
'Else
mydata.Read()
TextBox1.Text = mydata.Item("subhi")
TextBox2.Text = mydata.Item("zuhur")
TextBox3.Text = mydata.Item("aser")
TextBox4.Text = mydata.Item("megrib")
TextBox5.Text = mydata.Item("isha")
'End If
conn.Close()
Catch ex As Exception
MessageBox.Show("There is a problem with your connection!")
End Try
End Sub
如何解決這個問題?
是您正確的兄弟。現在我已經用整個代碼儘可能簡短地編輯了我的問題。謝謝! – ensberiyu