嗨,我收到一个 InvalidCastException 说“指定的演员表无效。”。我不知道问题出在哪里。我的代码有错误吗?
这是我的代码:
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\patientinfo.accdb"
Conn.Open()
'====retrieve values in database=============
Dim statement As String = " SELECT patient_name,patient_age,date_confinement,type_sickness, type_fluid, bottle_used, drop_rate FROM tblPatientInfo WHERE 1 ORDER BY ID "
RetrieveInfos(statement)
End Sub
Public Sub RetrieveInfos(ByRef statement As String)
Dim cmd As OleDbCommand = New OleDbCommand
With cmd
.CommandText = statement
.CommandType = CommandType.Text
.Connection = Conn
.ExecuteNonQuery()
'--read records in access database----------------
Dim reader As OleDbDataReader = cmd.ExecuteReader
If reader.Read Then
lblName.Text = reader.GetString(0)
lblAge.Text = reader.GetString(1)
lblDate.Text = reader.GetString(2)
lblSickness.Text = reader.GetString(3)
lblFluid.Text = reader.GetString(4)
lblBottle.Text = reader.GetString(5)
lbldrops.Text = reader.GetString(6)
reader.Close()
End If
End With
End Sub
任何帮助,将不胜感激。谢谢!:3