0

When I try to connect my MySql Database in web.config and create object in my class file it give me server error. My Connection string is bellow.

<add name="MyConn" providerName="MySql.Data.MySqlClient" connectionString="Server=localhost;User ID=root;Password=demo@123;Database=pay2school;port=3306;pooling=false;respect binary flags=false"/>

My Cs code is below

MySqlConnection conn = new MySqlConnection();
    string datacon;
    protected void Page_Load(object sender, EventArgs e)
    {

  datacon = ConfigurationManager.ConnectionStrings["MyConn"].ToString();
conn = new MySqlConnection(datacon);
//conn.ConnectionString = datacon;
  //  conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString);
    Response.Write(conn);
}

I got error is below

Server Error in '/WebSite1' Application. Keyword not supported. Parameter name: respect binary flags Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Keyword not supported. Parameter name: respect binary flags

Source Error:

   Line 20: 
    Line 21:       datacon = ConfigurationManager.ConnectionStrings["MyConn"].ToString();
    Line 22:     conn = new MySqlConnection(datacon);
    Line 23:     //conn.ConnectionString = datacon;
    Line 24:       //  conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString);

Please Help me.

2 Answers 2

1

Do you actually need that parameter? Could you take it out? i.e. change connection string to

<add name="MyConn" providerName="MySql.Data.MySqlClient" connectionString="Server=localhost;User ID=root;Password=demo@123;Database=pay2school;port=3306;pooling=false;"/>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply dear. Yes I relay need to do this.
0

Use ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.