connection string problem

  • Hi Folks,

    My SQL Server registration name is TEAM01\ERDEM

    I want to connect to this SQL Server databases via .NET. But I always get an error message.

    public

    static string connectionString = "server=TEAM01\ERDEM database=Northwind;User ID=sa;Password=mlsqlsys;"

    How can I rename this SQL Server registration or how can I connect via .NET with this registration name?

    Please help

     

  • Missing a semi-colon between server and database.

     

  • Thanks for your reply.But When I put a semicolon then I will get the same error message:

     

    -----------------------------------------------------------

    public

    static string connectionString = "server=TEAM01\xxxx;database=Northwind;User ID=sa;Password=mlsqlsys;";

    ----------------------------------------------------------

  • It is generally useful to include the actual text of the error message.

  • check out this url

    http://www.connectionstrings.com/

  • I would try putting the servername like [TEAM01\XXXX]

    oh..  and please tell me the password supplied is not the REAL one...  IF it is I would probably modify my post and change it....



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Or change it altogether and change the post to XXX just so that noone decides to try to hack your server.

  • I don't understand why you can't connect to your server... I connected just fine

  • I'm surprised you even compiled.  When I try to compile your code, I get an "Unrecognized escape sequence", which is roughly what I expected.

    In C#, the "\" in a string literal signifies that the following character should be treated special.  For example "\t" means interpret the "t" as a "tab".  And "\n" means interpret the "n" as a "newline".  To actually include a "\" in your string, you need to tell C# to interpret the "\" as a "\" by included two "\" as follows:

    public static string connectionString = "server=TEAM01\\xxxx;database=Northwind;User ID=sa;Password=xxxxxx;";

    Alternatively, you can tell C# to interpret the quoted string exactly as written by prefacing with a "@" as follows:

    public static string connectionString = @"server=TEAM01\xxxx;database=Northwind;User ID=sa;Password=xxxxxx;";

    Step through your code in debug mode and check that the connectionString variable contains exactly what you think it should.

  • Just a thought in case you were planning to use sa.  You may want to reconsider this.  The sa user should never be used within an application.  A specific id with minimal authority should be used.

     

    btw the connectionstring.com site is a great reference.  I didn't know about it.

    Francis

  • Thanks for your attentions...

    I have solved the problem by using "\\" instead of "\"

    I have also modified by connedtion string with all of your guidance as follows:

    --------------------------------------------------------------------

    public

    static string connectionString = "server=TEAM01\\ERDEM;database=ML2005;User ID=erdem_01;Password=SE7377;";

    -------------------------------------------------------------------

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply