Hi,
I hope this is right place to ask for help.If it is not, Please show me where and if it is please Help me
I using Window Vista bussiness, Microsoft visual 2005 professional edition, Microsoft SQL server express edtion
I have created table on Database.
My sql server name is KYAW-HQ
**but in the bar it shown like as KYAW-HQ\SQLEXPRESS
My data base name is kyaw
I have already Enabled Name Pipes and TCP/IP setting in sql studio management tool express
I using window authentication to log in to sql server management studio express.
My coding for c# is as follow:
private void button4_Click(object sender, EventArgs e)
{
//connect sql connection
SqlConnection con = new SqlConnection("Server=KYAW-HQ;Database=kyaw;UID=;PWD=;");
//open sql conection
con.Open();
SqlDataAdapter ad = new SqlDataAdapter("Select * From kyaw", con);
DataSet ds = new DataSet();
ad.Fill(ds, "kyaw");
dataGridView1.DataSource = ds.Tables[0].DefaultView;
con.Close();
}
After I click the button the error has shown like below
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).
Please tell me what i have to do.
If someone read me, please tell me and advice me how to fix above problem.
Thanks
Try the servername as "KYAW-HQ\SQLEXPRESS" in the code. And check whether the SQLExpress services are running|||SQL Service is running.But I cant connect to sql server.
I inerted the code like below
SqlConnection con = new SqlConnection("Server='KYAW-HQ\SQLEXPRESS';Database=kyaw;UID=;PWD=;");
But it has error
Unrecongnised escape sequence...
I tried like this as well
SqlConnection con = new SqlConnection("Server="KYAW-HQ\SQLEXPRESS";Database=kyaw;UID=;PWD=;");
please help me. I getting head-ache now.
|||
hi,
try removing the quotes..
Server =KYAW-HQ\SQLExpress;
BTW:
UID=;PWD=; ?
you will not be able to connect that way as you do not provide credentials for the login to be authenticated..
you can choose between integrated security (where you provide information your login should be validated as an OS login or domain login, and it's SID gets checked against "granted Windows Logins") or standard SQL Server authenticated connections (where you provide your "own" UID and PWD [but you have to provide them])..
please have a look as well at connections string samples..
regards
|||hi,
I removed the quotes and place
Server=KYAW-HQ\\SQLEXPRESS;Database=kyaw;UID=;PWD=;
the error come up it was different from previous
Login failed for user ''. The user is not associated with a trusted SQL Server connection.
if you have any idea and advice please advice me
Thanks
|||hi,
supermanNUM1 wrote:
hi,
I removed the quotes and place
Server=KYAW-HQ\\SQLEXPRESS;Database=kyaw;UID=;PWD=;
the error come up it was different from previous
Login failed for user ''. The user is not associated with a trusted SQL Server connection.
if you have any idea and advice please advice me
Thanks
you did not provide a valid SQL Server Login (and relative password) to connect to the SQLExpress instance.. more, SQLExpress installs by default enabling only trusted connections.. you can modify that behavior at install time, providing the SECURITYMODE=SQL parameter to the SQLExpress installer or, using the full "wizard ui", unchecking the "Hide advanced configuration options" and specify the desired mixed authentication mode in the following wizard's steps...
you can modify that behavior even later, at "run time", using SQL Server Management Studio Express, accessing the server's propery and, in the "security tab", specify "mixed authentication" (you are required to restart the SQL Server service)..
regards
|||Hi,Are you connecting using SQL server ID(eg. sa). IF yes pls check the authentication mode, if its in windows authentication then change it to mixed mode and restart Sql services.
For changing authentication mode, pls proceed as Andrea suggested
you can modify that behavior even later, at "run time", using SQL Server Management Studio Express, accessing the server's propery and, in the "security tab", specify "mixed authentication" (you are required to restart the SQL Server service)..
Then try connect using your code.
|||
I sorted it out
the code is
SqlConnection con = new SqlConnection("Server='KYAW-HQ\\SQLExpress';Database=kyaw;Trusted_Connection=true;");
Just used the Trusted_Connection=True
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2176838&SiteID=1
Thanks you for help
No comments:
Post a Comment