View Single Post
Old April 9th, 2006, 08:39 PM
vbswshare vbswshare is offline
Registered User
Join Date: Mar 2006
Location: Oshawa, , Canada.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks for the code update, it got rid of all the compile errors. I still have a problem when I try to run the program - I get the following error:

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I am using SQLExpress which might be the problem, can you tell me how to fix this problem? I have installed the Pubs database and it shows in SQL Express as well as in Server Explorer.

I have the same problem with a database that I have created from scratch, I'm trying to use this connection concept in it as well.

I still can't get it to work useing the entry in app.config, I would like to be able to use a getConnection function with the connection string in the app.config file and I can't seem to get that to work.

I did get a connection using the following code (in my own app):
Dim dr As SqlClient.SqlDataReader
        Dim conn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Crisis1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
        Dim command As SqlClient.SqlCommand = New _
            SqlClient.SqlCommand(storedProcedureName, conn)
        command.CommandType = CommandType.StoredProcedure
        dr = command.ExecuteReader(CommandBehavior.CloseConnect ion)
        While (dr.Read)
         (Read Stuff)
        End While

Can you tell me how to achieve this using your function/app.config concept? It's fine if it uses the code sample from the Pubs database - I can translate it to my database!