Hi all,
I'm trying to assign a result from a SQL query to my textbox, can anyone please tell me what I am doing wrong?
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim str As String
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Musab\My Documents\Visual Studio 2005\Projects\StudentDataBase\StudentDataBase\db2000.mdb")
cn.Open()
str = "Select EName FROM Table1 WHERE Tabel1.Num = " & TextBox1.Text & "'"
cmd = New OleDbCommand(str, cn)
dr = cmd.ExecuteReader
While dr.Read
test.Text = dr(1)
End While
cn.Close()
its complaining about the excutereader function.
Syntax Error in string in query expression 'Tabel1.Num = 222".
I'm trying to assign a result from a SQL query to my textbox, can anyone please tell me what I am doing wrong?
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim str As String
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Musab\My Documents\Visual Studio 2005\Projects\StudentDataBase\StudentDataBase\db2000.mdb")
cn.Open()
str = "Select EName FROM Table1 WHERE Tabel1.Num = " & TextBox1.Text & "'"
cmd = New OleDbCommand(str, cn)
dr = cmd.ExecuteReader
While dr.Read
test.Text = dr(1)
End While
cn.Close()
its complaining about the excutereader function.
Syntax Error in string in query expression 'Tabel1.Num = 222".