Results 1 to 4 of 4

Thread: [RESOLVED] still can't connect to sql server

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    Resolved [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

  2. #2
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Philippines
    Posts
    468

    Re: still can't connect to sql server

    Quote 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

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    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.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    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
  •  



Click Here to Expand Forum to Full Width