Today I tried to pass table name dynamically to select query as
cmd = New OdbcCommand ("select * from '" & table_name & "' where id=" & i & "", con)
But it failed. then fortunately got the correct one....
cmd = New OdbcCommand("select * from [" & table_name & "] where id=" & i & "", con)
Similarly avoid single quotes while using number.
eg: use id=" & i & " instead id=' " & i & " ' ,when id is number type.
cmd = New OdbcCommand ("select * from '" & table_name & "' where id=" & i & "", con)
But it failed. then fortunately got the correct one....
cmd = New OdbcCommand("select * from [" & table_name & "] where id=" & i & "", con)
Similarly avoid single quotes while using number.
eg: use id=" & i & " instead id=' " & i & " ' ,when id is number type.
No comments:
Post a Comment