asp.net - Error while executing a sql command in c# -


i using asp.net c# , there exist error in these line of codes.

protected void btnsubmit_click(object sender, eventargs e) {     string type = "c";     string fid = session["fid"].tostring();     sqlconnection cn = new sqlconnection();     sqlcommand cmd = new sqlcommand();     //int str_diff = convert.toint32(configurationmanager.appsettings["difference"]);     cn.connectionstring = @"data source=bopserver;initial catalog=project;integrated security=true";     cn.open();     cmd.commandtext = "update trackingfaculty_det set type=@type (fid=@fid) , datediff(d,trackingfaculty_det.lastupdatedate,getdate())>60";     cmd.parameters.add("@fid",sqldbtype.varchar,10);     cmd.parameters["@fid"].value = fid;     cmd.parameters.add("@type", sqldbtype.varchar, 1);     cmd.parameters["@type"].value = type;     cmd.executenonquery();     cn.close();      response.redirect("~/faculty/personaldet.aspx"); } 

error!!!

you haven't set connection command

cmd.connection = cn; 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -