Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

I cannot connect to Sql server

The following is my codes in a Ado.net program:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cn As New SqlConnection("data source=localhost;initial catalog=pubs;user id=sa;password=li08yuan")
Dim cm As New SqlCommand("Select * from Authors", cn)
Dim dr As SqlDataReader
cn.Open()------'Procedure is stop here
dr = cm.ExecuteReader
dr.Read()
Response.Write("Name: " & dr("au_fname") & " " & dr("au_lname"))
dr.Close()
cn.Close()
End Sub
[622 byte] By [liangchu] at [2007-11-11 8:02:01]
# 1 Re: I cannot connect to Sql server
Hi,

I didnt get you wat u r saying because same code works fine for me.
Please provide details.
rupeshbartakke at 2007-11-11 21:48:08 >
# 2 Re: I cannot connect to Sql server
What is the error message?
pclement at 2007-11-11 21:49:09 >
# 3 Re: I cannot connect to Sql server
Check SQL Server Service is running. Check that mixed mode authentication is enabled. Check that SQL Servier is installed as a default instance on the local computer.

Please post back with full details of any error messages.
Wiseman82 at 2007-11-11 21:50:07 >
# 4 Re: I cannot connect to Sql server
The error message is :System.Data.SqlClient.SqlException.
The user as 'sa' cannot connect to server on localhost.
liangchu at 2007-11-11 21:51:07 >
# 5 Re: I cannot connect to Sql server
Sounds like the sa password is incorrect. Can you verify that "li08yuan" is the correct password?
pclement at 2007-11-11 21:52:17 >
# 6 Re: I cannot connect to Sql server
The error message :System.Data.SqlClient.SqlException and it says that user 'sa' login on SqlServer failure.I have tried to use password "li08yuan" but It has still not done.By the way,How to do run the SQL server.I'm beginner for SQL Server.thanks a lot.
liangchu at 2007-11-11 21:53:16 >
# 7 Re: I cannot connect to Sql server
I don't know which version of SQL Server you are using but you can use Enterprise Manager to manage the database.

The sa user ID is blank by default. If you never changed the password then it should still be blank.
pclement at 2007-11-11 21:54:15 >