locked
Cannot Open Database. Login Failed. RRS feed

  • Question

  • I am a newbie in sql server and i am creating a web application using VB.NET

    I have a button that when i click it will open the database. Heres the code:


        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            Dim sqlConnect As New SqlConnection("integrated security=SSPI;data source=(local)\SQLEXPRESS;persist security info=False;initial catalog = CorporateDB;")
      
            sqlConnect.Open()

        End Sub

    the problem is when i clicked the button an error will show:

    Cannot open database "CorporateDB" requested by the login. The login failed. Login failed for user 'TRANSLTR\ASPNET'.


    The CorporateDB is the database. And i don't know where did i got this user 'TRANSLTR/ASPNET' My computer name is Transltr but not 'TRANSLTR/ASPNET'.

    I tried using this connection string in creating windows application in VS.NET. It works fine. What did i missed here. Please i need your help.

    Tuesday, May 8, 2007 3:56 PM

Answers

  • ASPNET = Windows Authentication. You need to configure a generic SQL Authentication or use your own. Either way you have to change your connection string to the following format:

    Data Source=ServerName;Initial Catalog=DataBaseName3;UId=UserLoginName;Password=Password;Trusted_Connection=False"

     

    You can also use impersonation in the your web.config file. It's up to you.

     

    Adamus

    Tuesday, May 8, 2007 4:02 PM

All replies

  • ASPNET = Windows Authentication. You need to configure a generic SQL Authentication or use your own. Either way you have to change your connection string to the following format:

    Data Source=ServerName;Initial Catalog=DataBaseName3;UId=UserLoginName;Password=Password;Trusted_Connection=False"

     

    You can also use impersonation in the your web.config file. It's up to you.

     

    Adamus

    Tuesday, May 8, 2007 4:02 PM
  • Can you show me the steps on:

    1. How can i configure a generic SQL Authentication

    2. using inpersonation web.config

    I apologize for all this trouble. I'm still a newbie in ms sql. Thanks for replying.
    Tuesday, May 8, 2007 6:29 PM
  • Just use the connection string I've posted and put the login and password you use to log into SQL. If you use Windows Authentication, add this line to your web.config file:

     

    <system.web>
    <identity impersonate="true" userName="WindowsDomain\YourUserName" password="YourPassword" />
    </system.web>

    Adamus

    Tuesday, May 8, 2007 6:38 PM