i built application using asp.net , entityframework database here connectionstring of context class
<add name="estringspbcontext" connectionstring="connection string: data source=localhost; initial catalog=estringspb;integrated security=false;user id=sqladmin;connect timeout=15; encrypt=false;packet size=4096;multipleactiveresultsets=true; app=entityframework;persist security info = true" providername="system.data.sqlclient"/> when try login throws error
it works on local machine when uploaded on hosting server throws following error
"this operation requires connection 'master' database. unable create connection 'master' database because original database connection has been opened , credentials have been removed connection string. supply unopened connection."
here login code
string emailid ="johnddoe@gmail.com"; userentity user = new userentity(); using (estringspbcontext db = new estringspbcontext()) { var objuser = (from obj in db.users obj.emailid == emailid select obj).singleordefault(); user = (userentity)objuser; db.dispose(); } if (user.password == txtadminpassword.value) { //if (user.onlinestatus == false) //{ using (sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["defaultconnection"].connectionstring)) { using (sqlcommand cmd = new sqlcommand("update usersdetails set onlinestatus = '" + true + "' emailid ='" + user.emailid.tostring() + "'", con)) { con.open(); cmd.executenonquery(); con.close(); } } }
i think have update connection string per hosting server..like have change server.
<add name="estringspbcontext" connectionstring="server=ipofserver;initial catalog=estringspb;trusted_connection = true ;multipleactiveresultsets=true;app=entityframework;" providername="system.data.sqlclient"/>
Comments
Post a Comment