Cant connect to the SQL Server :S

Associate
Joined
30 Sep 2004
Posts
2,301
Location
City of Rain
Hi guys

I keep getting this error msg:

"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)"

even after I have configured my SQL Server according to this guide:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

my code looks like this:

Dim Max As ArrayList = New ArrayList
Dim myConn As SqlConnection
myConn = New SqlConnection("Server=myserver;Database=mydb;User ID=username;Password=pass;Trusted_Connection=False;")
Dim command As SqlCommand = New SqlCommand("SELECT Max FROM tblTemp;", myConn)
myConn.Open()
Dim reader As SqlDataReader
reader = command.ExecuteReader()
While reader.Read()
Max.Add(reader("Max"))
End While

reader.Close()
myConn.Close()
MsgBox(Max.Count)

anyone have any ideas?

thanks
ken
 
Last edited:
have you tried connecting directly using some sql management software to ensure the username and password is ok. also make sure sql authentication is on as by default it used windows authentication.

if you have a look on the net theres some help in getting it switched to sql authentication or you might have to reinstall sql server as it was an option when you installed it.
 
Gman said:
have you tried connecting directly using some sql management software to ensure the username and password is ok. also make sure sql authentication is on as by default it used windows authentication.if you have a look on the net theres some help in getting it switched to sql authentication or you might have to reinstall sql server as it was an option when you installed it.

thanks for the quick reply :) when I added a new connection, I did chose "Use SQL Server Authentication" in the "Log on to the server" tab. Also, I just done an test connection which was successful as shown:

testconnectionyy4.png


no ideas what causing this :(

p/s: what sql management software can I use to test the connection?

update: it seems working now :confused:
 
Last edited:
ummm....here comes another problems :S it seems like it doesnt pass any data to my arraylist (the Max.Count returns zero) :o
 
Last edited:
Back
Top Bottom