sql server - SQL SELECT statement (in vb.net) returning empty and/or weird rows -
i using vs express 2012, sql server 2012. have 1 table (computers) , 2 rows 10 columns (hahu_id, serial_number, brand, model, os, processor, hdd, memory, st, speed).
i've been on site reading many posts can trying create vb.net interface sql server. succeed @ connecting them , returning values datagridview table
select * computers
but when tried other commands
select * computers 'hahu_id' = '101'
it returns empty datagridview row! tried changing 'hahu_id' random, still gave me empty rows. correct column names displayed rows empty.
when tried command "select 'hahu_id', 'brand' computers" , returned:
column1---|--column2 -hahu_id--|--brand -hahu_id--|--brand
the column names have been changed "column1 , column2" , can see rows filled should column names! frustrated tried "select 'hahu', 'brand_id' computers" (non existing columns in database) , returned with:
column1---|--column2 ---hahu----|--brand_id ----hahu---|--brand_id
i went original select * computers
, works again!
here code:
dim cs new sqlconnection... cs.open() 'dim da2 new sqldataadapter("select * computers 'hahu_id' = '101'", cs) dim da2 new sqldataadapter("select * computers", cs) dim table new datatable() table.locale = system.globalization.cultureinfo.invariantculture da2.fill(table) bindingsource1.datasource = table datagrid1.datasource = bindingsource1 cs.close()
(i couldn't copy , paste because i'm on computer now). select * computers
statement works try else doesn't work.
why that? thanks.
don't put single quotes around column names. hahu_id = '101' correct.
Comments
Post a Comment