Visual Studio 2005 "How do you create a new sql database?"

garyjos

New member
Joined
Nov 17, 2005
Messages
4
Programming Experience
Beginner
Visual Studio 2005 "How do you connect/create a new sql database?"

Hello


I have just got the trial dvd for Visual Studio 2005 Professional
When trying to make a new sql server database, I get an error box:-

********************************************************************************************************
An error has occured while establishing a connection to the server. When connecting tp 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 Provide, error: 40 - Could not open a connection to SQL Server)
********************************************************************************************************

My sql server is shown on my computer via server explorer, but it appears that sql is not configured correctly?

I just want it to work on the local machine, can you please help?

(I just want to connect to my SQL local server and create a new database via server explorer from Visual Studio)


Thanks
Gary.
 
Last edited:
Gary - what was your connection code?

Here is code that works in connecting to SQLExpress:

VB.NET:
Imports Microsoft SQLServer.Management.Common
Imports Microsoft SQLServer.Management.SMO
Public SQLServer as Server
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] SC [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] ServerConnection = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ServerConnection
[/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]  ' Recreate connection if necessary
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]  If[/COLOR][/SIZE][SIZE=2] SC [/SIZE][SIZE=2][COLOR=#0000ff]Is[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]         SC = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ServerConnection
[/SIZE][SIZE=2][COLOR=#0000ff]  End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2]  SC.ServerInstance = [/SIZE][SIZE=2][COLOR=#800000]"(ComputerName)\SQLExpress"
[/COLOR][/SIZE][SIZE=2]  SC.SqlExecutionModes =   SqlExecutionModes.ExecuteAndCaptureSql
   SC.ConnectTimeout = 15 [/SIZE][SIZE=2][COLOR=#008000]'time in seconds
[/COLOR][/SIZE][SIZE=2]  SC.LoginSecure = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'Use Windows Authentication
[/COLOR][/SIZE][SIZE=2]  SC.Connect()
   SQLServer = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Server(SC)
[/SIZE][SIZE=2][COLOR=#0000ff]  Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] ConnectionFailureException
[/SIZE][SIZE=2]      (error handling)[/SIZE]
[SIZE=2][COLOR=#0000ff]  Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] SmoException
[/SIZE][SIZE=2]      (Error handling)[/SIZE]
[SIZE=2][COLOR=#0000ff]  Finally
           (Restore stuff)[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#008000]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE]

If you can get connected, I can give you code for creating the database.

In the SQL Server Configuration Manager, Protocols for SQLExpress, be sure that Named Pipes is enabled.


Don Seydel
 
Dear Don,
I have encountered exactly the same error. .NET technology is all but ancient Greek to me, I am just getting into all this.
Could you please clarify where exactly to place this connection code?
You can just reply or e-mail me at jkuliyev@gosignet.com

Thank you so much for any help you can give!

Jeff
 
Open SQL Server Management Studio.
After making a connection, right click on the server in the object browser.
Select Properties.
Click on the "Connections" section.
You should now be seeing the connection properties scren.
attachment.php


-tg
 

Attachments

  • remoteconnections.JPG
    remoteconnections.JPG
    64.1 KB · Views: 142
Back
Top