MySQL Connection string to Context
Posted by: Samantha Martin
Date: March 15, 2013 07:57AM

I am trying to figure out how to pass a MySQL connection string through a datacontext. I keep getting a exception thrown when it gets to the DataContext "login failed at user: root". I believe it thinks im using SQL Server and I do not know where I am going wrong. Any guidance would be appreciated.
Its an app the the user plugs in the values to the database and it gets the info to and from the database.


//This gets the values the user enters to access the databse and returns the //string to where its needed

private string MustangConnString()
{
string connStr = ("persist security info = true;server=" + Server + ";uid=" + username + ";database=" + Database + ";pwd=" + Password + );

MySqlConnection myConnectionString = MySqlConnection(connStr);

myConnectionString.Open();

return myConnectionString.ConnectionString;
}

//This is where the connection string is needed
private void ect (bool oneanddon)
{

MySqlConnection myConnectionString = new MySqlConnection(ConnectionString);
myConnectionString.Open();

//I am getting the error here, Like I said I believe it thinks im trying to log //into an SQL servr database and I don't know how to solve this.
using (var MessageConn = new DataContext(myConnectionString.ConnectionString))
{
var cos = MustangConn.COS.ToList();
}

}

Options: ReplyQuote


Subject
Written By
Posted
MySQL Connection string to Context
March 15, 2013 07:57AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.