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"); }
you haven't set connection command
cmd.connection = cn;
Comments
Post a Comment