c# - DataGridView gives an error if a table field is binary type -
for reasons, need write own sqlquery tool. works.
but when select table contains binary type, gives me error i've shown below.
i used datagridview. code below.
private void button1_click(object sender, eventargs e) { string sql = txtsql.text.trim().tostring(); try { gridresult.datasource = getdataset(sql).tables[0]; } catch (sqlexception err) { messagebox.show("error : " + err.message + "-" + err.number); } } public dataset getdataset(string sql) { sqlconnection conn = new sqlconnection(connstr); sqldataadapter da = new sqldataadapter(); sqlcommand cmd = conn.createcommand(); cmd.commandtext = sql; da.selectcommand = cmd; dataset ds = new dataset(); conn.open(); da.fill(ds); conn.close(); return ds; }
i wonder, there way prevent showing binary area or prevent giving error? should now? or have idea how can detect type of binary field when loading gridview programatically?
Comments
Post a Comment