sqlConnection problem
visual studio 2005
here's my connection..
SqlConnection connect = new SqlConnection("Data Source=localhost; Integrated Security=SSPI;" + "Initial Catalog=dbname";);
i don't if this is the problem or what. i just created a database inside this visual studio which is the ms sql server. the error says...
an error has occurred while establishing a connection to the server. when connecting to Sql Server 2005, the 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)
i even tried allowing local and remote connection in the settings but still it doesn't work. and i think, i don't need to do that because I'm not connecting remotely. i don't know that's how i understand it..
pls help me! tnx
bhargavPosted Apr 18, 2007, 8:39 AM
InitialCatalog=Testdb;DataSource=.\\sqlexpress;Pooling=True;User ID=sa;Password=sa
wafflePosted Mar 20, 2007, 9:05 AM
GurdeepPosted Mar 14, 2007, 11:05 AM
Dim conTransit As SqlConnection
conTransit = New SqlConnection("Server=SERVER;Database=DATABSE;Integrated Security=SSPI")
'YOU COULD USE --- [User ID=USER;Password=PASSWORD] INSTEAD OF [Integrated Security=SSPI]if your sqlserver does
'not have windows default access
Try
'Try the SQL-SERVER connection
conTransit.Open()
'Additonal check statements
If conTransit.State = ConnectionState.Open Then
MessageBox.Show("Connection OK" & "" & conTransit.ConnectionString)
Else
MessageBox.Show("Could not open SQL database Connection : " & "" & conTransit.ConnectionString)
End If
' -----------------------Genrate error meaasge-------------------------------------
Catch er As System.Data.SqlClient.SqlException
MsgBox("You have Problem generating SQL Server Connection" & "--->" & er.Message, MsgBoxStyle.Critical, "MY SYSTEM ERROR!")
End Try
Enjoy................
Keith RoeschPosted Mar 12, 2007, 8:41 AM
Hello,
Do as follows
Under sql server 2005 go into configuration and select SQL Server surface and configuration.
Click the link for Surface Area Configuration for Services and Connections
next for standard SQL conections expand Database Engine, then click Remote Connections.
There you will select local and remote connections and also select Using both TCP/IB and named pipes.
If you use SQLExpress expand and use the above sitings here also.
any questions
http://www.terranettech.net