how can i connect to database from IIS 5.1

308 views Asked by At

When I want to connect to my site database via the local network، This message will appear:

Cannot log in to my_server_name/AspNet

My connection string is:

<connectionStrings>
    <add name="behbahan_cementConnectionString" connectionString="Data Source=MAYA-1307F9F334\SQLEXPRESS;Initial Catalog=behbahan_cement;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>`

I can't connect to the database?

2

There are 2 answers

1
H. Mahida On

Standard way to connect Database as;

          <connectionStrings>
          <add 
                 name="NorthwindConnectionString" 
                 connectionString="Data Source=serverName;Initial 
                 Catalog=Northwind;Persist Security Info=True;User 
                ID=userName;Password=password"
                providerName="System.Data.SqlClient"
          />
          </connectionStrings>

What I can See here is you are messing ;

           ID=userName;Password=password"

to connect the database in connectionString. Default username and password should be "root" unless you have changed it. Try to connect with this detail. Thanks,

0
Damon On

I'd suggest you first try and establish whether you can connect to the database from outside the web application either via SQL Server Management Studio or by using a .UDL file. I've answered a question on testing a SQL server connection here.

Based on the results of these tests it may become apparent to you what the problem may be. In your case, you are using integrated security (which you would need to be on a domain to use over the network). If you are not on a domain, a username and password may need to be supplied.