dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: [RESOLVED] Connecting to SQL Server

  1. #1
    Join Date
    Apr 2007
    Posts
    395

    resolved [RESOLVED] Connecting to SQL Server

    Im trying to connect to a database, but it keeps saying "The ConnectionString property has not been initialized. " Im not sure what its refering to, my code or my connection string, Im using windows authentication in SQL Server Management. But not sure what I need to do here


    Web.config
    <connectionStrings>
    <add name="MyDbConn1" connectionString="Server=MyServer;Database=Omni_Test;Trusted_Connection=Yes;"/>
    </connectionStrings>


    Function
    Dim DBConnect As SqlConnection = Connection()
    DBConnect.Open()

    DBConnect.Close()



    Private Shared Function Connection() As SqlConnection
    Dim sConnection As String = System.Configuration.ConfigurationManager.AppSettings("MyDbConn1")
    Return New SqlConnection(sConnection)
    End Function

  2. #2
    Join Date
    Apr 2007
    Posts
    395
    Looks Like Ive upgraded my Error now it says

    A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)



    Im pretty sure its the connection string but I don't now what to put in there?

  3. #3
    Join Date
    Apr 2007
    Posts
    395
    Or if I try to use Integrated Security=True in the connection string it says

    Cannot open database "Omni_Test.dbo" requested by the login. The login failed.
    Login failed for user 'NATHANCO-5AC28D\Nathan'.

  4. #4
    Join Date
    Mar 2006
    Posts
    591
    Make sure your windows account has the permission to login to your sql server. It seems that you can not login with this username.

    Have you tried logging in with an sql account?

  5. #5
    Join Date
    Apr 2007
    Posts
    395
    I figured it out was the connection string, I just changed it

    <appSettings>
    <add key="ConnectionString"
    value="Server=ServerName;Database=DBName;Integrated Security=True" />
    </appSettings>


    Now it works

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles