I want to use a database on my asp.net website, but i have some problems with connecting to my host. I use the following code and i got an error:
private const string ConnStr = "Provider=MSDASQL; Driver={MySQL ODBC 5.1 Driver};Server=pdb9.xxx.net;Database=xxx;User=xxx;Password=xxx;Option=3;";
using(OdbcConnection con = new OdbcConnection(ConnStr))
using(OdbcCommand cmd = new OdbcCommand("INSERT INTO sample(name, address) VALUES (?,?)", con))
{
cmd.Parameters.Add("@name", OdbcType.VarChar, 255).Value = TextBox3.Text.Trim();
cmd. Parameters.Add("@address", OdbcType.VarChar, 255).Value = TextBox4.Text.Trim();
con.Open();
cmd.ExecuteNonQuery();
BindDataGrid();
}
The error appears when i call con.open();
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I always used the MySQL database on my PHP pages and it worked fine. Besides Mysql my host also supports PostgreSQL. Does someone know how i can solve this problem or how to find a solution using a database on an asp.net page?