简体   繁体   中英

Not connecting to database from local website

I have hosted a website in my local machine IIS. The login page is loading fine, but after I enter the credentials, it is not not redirecting me to the homepage, it just stays on the same login page.

This is the connection string that I am using:

    <add name="MyConn" connectionString="server=ajaymeda-pc;database=RoomExpenses;Trusted_Connection=true;"/>
</connectionStrings>

PS: I have lost the source code and only have the compiled version.

First, ensure that the connection information is correct (server and database name). Then make sure that 'Remote Connections' are enabled in SQL.

Also, since it is .Net, you could grab a .Net decompiler (perform a Google search) that will allow you to decompile the DLLs and view the most of the source code. This is probably your last option, but would allow you to at least view what the page is doing and gives you a starting point if you had to redevelop the site.

use this as connection string if this is the issue as you mention:

  <connectionStrings>
    <add name="ConnStringDb1" connectionString="Data Source=localhost;Initial Catalog=RoomExpenses;Integrated Security=True;" providerName="System.Data.SqlClient" />
  </connectionStrings>

UPDATE #1

you call this connection string inside your code like below:

using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStringDb1"].ToString()))
{
   try
   {}
   catch
   {}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM