-
select query
Code:
Public con As OleDbConnection
Public cmd As OleDbCommand
Public dr As OleDbDataReader
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\student.mdb;")
con.Open()
str = "select name," & textbox1.text & " from Table1" 'textbox1.text="Address"
cmd = New OleDbCommand(str, con)
dr = cmd.ExecuteReader()
While dr.Read()
MsgBox(dr(0))
MsgBox(dr(1))
End While
dr.Close()
what wrong in this querry ?
it give error in dr(1) ..
-
Re: select query
Well, does Table1 contain a column named "Address" ?
You are missing a closing quote after Table1 in your SQL query text, however I imagine that was done during posting, and not in your real code, as it would not even run as it is above.
-
Re: select query
Doesn't the code editor report syntax errors?
You have syntax errors both in SQL syntax and VB syntax.
I seriously doubt you enter the Column name in your textbox1, and if you need to specify a criteria you must provide WHERE keyword:
Code:
SELECT ColumnName1, ColumnName2 FROM TableName WHERE ColumnNameN=Value;
-
Re: select query
sorry , i did typing mistake while posting code in vbforum
Yes table contain column address
-
Re: select query
You can do dr(0) without .tostring ?
Just questioning myself i don't have .net here.
-
Re: select query
Tell us the exception message.