vb.net - table.keyfield=table.field2 gives (0x80131904): An expression of non-boolean type specified in a context where a condition is expected -
first post
i have been struggling hours today , have not been able find on web.
i have vb.net program runs query string read configuration file needs configurable (not problem). queries work fine below code long there no clause '=' isn't boolean. (ex table1.fieldkey=table2.key)
i error: system.data.sqlclient.sqlexception (0x80131904): expression of non-boolean type specified in context condition expected, near 'key'.
code:
public sub doquery() dim cn new sqlconnection(), cmd new sqlcommand(), schematable datatable, myreader sqldatareader, myadapter new sqldataadapter() dim myfield datarow, myproperty datacolumn dim j integer = 0 dim queryoutput new datatable 'open connection sql server cn.connectionstring = connectstring cn.open() 'retrieve records cmd.connection = cn cmd.commandtext = query try myreader = cmd.executereader() catch ex exception writelog("an error occured. check sql query" & chr(13) & ex.tostring) exit sub end try using cn myadapter.selectcommand = cmd myadapter.fill(queryoutput) end using cn.close() end sub
query:
select ta.[key], ta.name, ta.currentstationkey station, te.discriminator type, ta.material, ta.materialdescription trackedassets ta, trackingevents te ta.[key]=te.assetkey
what doing wrong? seems connection string can't handle field=field.
Comments
Post a Comment