sql server - error in connecting to sql from C# windows form application -
i have form in c# user , pass , form shows informations of employees 2 tables in sql server want show in gridview.
private void button1_click(object sender, eventargs e) { string userid = textbox1.text; string passwrd = textbox2.text; sqlconnection myconnection = new sqlconnection("server=.,sql2014;database=mytamrin;uid=sa;password=sa123;"); try { myconnection.open(); } catch (exception r) { messagebox.show(r.tostring()); console.writeline(r.tostring()); } sqlcommand sqlcomm = new sqlcommand(); sqlcomm.commandtext = "select count(*) dbo.empp fldusername = @snum , fldpassword = @pass"; sqlcomm.parameters.addwithvalue("@snum", userid); sqlcomm.parameters.addwithvalue("@pass", passwrd); if ((int16)sqlcomm.executescalar()==1) { userinfo mainform = new userinfo(); mainform.show(); }
what problem?
you're not specifying the:
sqlcomm.connection = myconnection;
Comments
Post a Comment