连接字符串属性尚未初始化

时间:2014-11-19 23:24:26

标签: vb.net

我正在尝试使用以下代码搜索我的数据库,但是我收到了上述错误。

 Private Sub ButtonSearch_Click(sender As System.Object, e As System.EventArgs) Handles ButtonSearch.Click

    myConnection.Open()
    Textlocation.Clear()

    Dim str As String
    str = "select * From STUDENTS where ADMINNO like " & "'%" & SearchTextBox.Text & "%'"
    Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
    dr = cmd.ExecuteReader
    While dr.Read()
     Textadminac.Text = dr("ADMINNO").ToString
    End While
    myConnection.Close()

End Sub

0 个答案:

没有答案