Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2005
    Posts
    74

    Unanswered: probblem with my connection string

    hi guys! i'm having problem with my connection string below the error is
    The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.
    can anybody please help me. Thanks in advance!!
    Code:
            public SqlConnection sqlConn;
            public bool  db_Connection()
            {
                try
                {
                    //string sqlConnStr = Properties.Settings.Default.MyConnString;
                    string sqlConnStr = @"Data Source = DAIMOUS\SQLEXPRESS; Initial Catalog=BCMDDB; User ID=test; Password=test";
                    sqlConn = new SqlConnection(sqlConnStr);
                    sqlConn.Open();
                    return true;
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    MessageBox.Show("db_Connection Function error:" + ex.Message, "BCMD");
                    return false;
                }
            }

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    I am not familiar with C#.NET syntax. What is the @ before the connection string?

    The error does not give a lot of information. I am not sure it implicates the connection string, but you can check the parameters at www.connectionstrings.com.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •