|
-
Feb 27th, 2007, 06:02 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] still can't connect to sql server
I get this error message:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - The specified network name is no longer available.)
This occurs when I try to open connection. Here is code:
Code:
string conStr = "Server=www.freesqlserver.com;Database=mytable;UID=john1;PWD=pass1;";//not actual user-pass
System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(conStr);
System.Data.SqlClient.SqlCommand cmd;
cmd = new System.Data.SqlClient.SqlCommand("Select * from mytable", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
note: There is no database created yet in this server.
Last edited by Hack; Feb 28th, 2007 at 12:19 PM.
Reason: Added [RESOLVED] to thread title and green "resolved" checkmark
-
Feb 27th, 2007, 06:30 PM
#2
Hyperactive Member
Re: still can't connect to sql server
 Originally Posted by benmartin101
I get this error message:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - The specified network name is no longer available.)
This occurs when I try to open connection. Here is code:
Code:
string conStr = "Server=www.freesqlserver.com;Database=mytable;UID=john1;PWD=pass1;";//not actual user-pass
System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(conStr);
System.Data.SqlClient.SqlCommand cmd;
cmd = new System.Data.SqlClient.SqlCommand("Select * from mytable", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
note: There is no database created yet in this server.
what table are you connecting to?
and make sure that the user has a privelege to access the database you are connecting to
if you have a problem face  it
but what if your face  is your problem
how can you face  it 
-
Feb 27th, 2007, 06:40 PM
#3
Re: still can't connect to sql server
You can't connect to a database that does not exist.
When you login to sql server you connect to the Master database (unless a default is assigned to the login). If you specify a database in the connection string, the login process will attempt to switch you to that database.
-
Feb 28th, 2007, 11:46 AM
#4
Thread Starter
Frenzied Member
Re: still can't connect to sql server
Thanks. It's working now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|