sql server - An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll in Winform -
i'm using sql server 2014 , code:
void loadproductsinfor() { sqlconnection con = new sqlconnection(); con.connectionstring = @"server=.\sqlexpress;database=cnet_block3;uid=sa;pwd=123456;integrated security=true"; con.open(); sqlcommand cmd = new sqlcommand(); cmd.connection = con; cmd.commandtype = commandtype.text; cmd.commandtext = "select * products"; sqldatareader dr = cmd.executereader(); // exception happens here while (dr.read()) { datagridview1.rows.add(dr[0].tostring(), dr[1].tostring(), dr[2].tostring(), dr[3].tostring(), dr[4].tostring(), dr[5].tostring(), dr[6].tostring(), dr[7].tostring(), dr[8].tostring(), dr[9].tostring(), dr[10].tostring()); } dr.close(); con.close(); }
i tried many things didn't work.
Comments
Post a Comment