c# - Local Database not working -


i have working mvc5. have created portal site working server db connection after have created local db connect local sql server not connect db. server db connection using

appseetings.config    <?xml version="1.0"?>     <appsettings>        <add key="webpages:version" value="2.0.0.0" />       <add key="webpages:enabled" value="false" />       <add key="preserveloginurl" value="true" />       <add key="clientvalidationenabled" value="true" />       <add key="unobtrusivejavascriptenabled" value="true" />        <add key="defaultmembershipname" value="username" />        <add key="smtpserver" value="relay-hosting.secureserver.net" />       <add key="smtpport" value="25" />       <add key="userid" value="thenna41@gmail.com" />       <add key="password" value="pixel@1990" />         <add key="defaulttheme" value="theme1"/>       <add key="webpages:version" value="3.0.0.0" />       <add key="webpages:enabled" value="false" />       <add key="clientvalidationenabled" value="true" />       <add key="unobtrusivejavascriptenabled" value="true" />          <!--<add key="thenna" value="server=121.11.1.2;database=montage;user id=montage;password=pass;trusted_connection=false;"/>-->            <!--<add key="thenna" value="server=desktop-qd6a981\sqlexpress;user id=montage;password=montage;trusted_connection=false;" />-->            <add key="thenna" value="server=desktop-qd6a981\sqlexpress;trusted_connection=true;" />            <add key="customauthentication.loginurl" value="/account/logon" />           <add key="customauthentication.cookie.name" value=".custom_auth" />           <add key="customauthentication.cookie.expiration" value="1" />           <add key="customauthentication.cookie.timeout" value="20" />          </appsettings> 

i have called local db config not working

key="thenna" --> used read string db connection

appsettings reader using read thenna key value

public class homesqlrepository : repository     {         public string connectionstring { get; set; } = appsettingsreader.readstring("thenna");         const int maxitemcount = 1000;         public enum sqlexecutetype         {             scalar, nonquery, reader         }         public async task<string> executesqlasync(string procname, sqlexecutetype executiontype, idictionary<string, string> parameters)         {             string ret = "";              using (sqlconnection sqlconn = new sqlconnection(connectionstring))             {                 using (sqlcommand sqlcmd = new sqlcommand(procname, sqlconn))                 {                     sqlcmd.commandtype = commandtype.storedprocedure;                     foreach (keyvaluepair<string, string> kvp in parameters)                     {                         sqlcmd.parameters.addwithvalue(kvp.key, kvp.value);                     }                     sqlconn.open();                     if (executiontype == sqlexecutetype.scalar)                         ret = (await sqlcmd.executescalarasync()).tostring();                     else if (executiontype == sqlexecutetype.nonquery)                         ret = (await sqlcmd.executenonqueryasync()).tostring();                     sqlconn.close();                 }             }              return ret;         }          public t  getitem<t>(string procname, idictionary<string, object> parameters)         {              procname.throwifnull();                using (idbconnection db = new sqlconnection(connectionstring))             {               var result= db.query<t>(sql: procname, param: buildqueryparameter(parameters), commandtype: commandtype.storedprocedure);                 return result.firstordefault();             }           } 

app settings reader using cloudconfirmationmanager using following code

  public static class appsettingsreader     {         public static string readstring(string key)         {             try             {                 return cloudconfigurationmanager.getsetting(key).tostring();             }             catch(system.exception ex)             {                 throw ex;             }         }          public static int readint(string key)         {             try             {                 return int.parse(cloudconfigurationmanager.getsetting(key).tostring());             }             catch (system.exception ex)             {                 throw ex;             }         } } 

where reading value have created db local not working when connect server working. mistake here ? in advance


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -