sql - SQLDataReader Invalid object name -
i trying authenticate user through login form reading user details database usersdb. on attempting read, error: invalid object name: usersdb
i got no errors when adding new user database not know why getting error. here stack trace getting:
[sqlexception (0x80131904): invalid object name 'usersdb'.] system.data.sqlclient.sqlconnection.onerror(sqlexception exception, boolean breakconnection, action`1 wrapcloseinaction) +388 system.data.sqlclient.tdsparser.throwexceptionandwarning(tdsparserstateobject stateobj, boolean callerhasconnectionlock, boolean asyncclose) +810 system.data.sqlclient.tdsparser.tryrun(runbehavior runbehavior, sqlcommand cmdhandler, sqldatareader datastream, bulkcopysimpleresultset bulkcopyhandler, tdsparserstateobject stateobj, boolean& dataready) +4403 system.data.sqlclient.sqldatareader.tryconsumemetadata() +82 system.data.sqlclient.sqldatareader.get_metadata() +135 system.data.sqlclient.sqlcommand.finishexecutereader(sqldatareader ds, runbehavior runbehavior, string resetoptionsstring) +6666037 system.data.sqlclient.sqlcommand.runexecutereadertds(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, boolean async, int32 timeout, task& task, boolean asyncwrite) +6667856 system.data.sqlclient.sqlcommand.runexecutereader(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, string method, taskcompletionsource`1 completion, int32 timeout, task& task, boolean asyncwrite) +577 system.data.sqlclient.sqlcommand.runexecutereader(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, string method) +107 system.data.sqlclient.sqlcommand.executereader(commandbehavior behavior, string method) +288 system.data.sqlclient.sqlcommand.executereader() +302 authwebrole.account.userlogin.buttonlogin_click(object sender, eventargs e) in c:\users\tamara\documents\visual studio 2012\projects\tcwalletazure\authwebrole\account\userlogin.aspx.cs:32 system.web.ui.webcontrols.button.raisepostbackevent(string eventargument) +155 system.web.ui.page.processrequestmain(boolean includestagesbeforeasyncpoint, boolean includestagesafterasyncpoint) +3804
edit:
the query follows: (i replaced username , password in code)
string strcon = "server=tcp:qemcclhlar.database.windows.net,1433;database=usersdb;user id=[userid];password=[mypassword];trusted_connection=false;encrypt=true;connection timeout=30"; sqlconnection con = new sqlconnection(strcon); sqlcommand com = new sqlcommand("checkuser", con); com.commandtype = commandtype.storedprocedure; sqlparameter user = new sqlparameter("username", username.text); sqlparameter pword = new sqlparameter("password", password.text); com.parameters.add(user); com.parameters.add(pword); con.open(); sqldatareader rd = com.executereader(); if (rd.hasrows) { rd.read(); labelinfo.text = "login successful."; } else { labelinfo.text = "invalid username or password."; }
database schema:
database: usersdb table usertable
well important thing here connection string. following: create empty text file , rename "myconnection.udl". double click on file , launch applet. can configuer connection database , test it. open udl file in notepad, see correct connection string. copy connections string app connection settings. udl files misunderstood. text file holds connection settings. call connection dll. if udl file works have correct connection string 100%
Comments
Post a Comment