To configure the mysql database  with asp.net  from a remote pc  here are the things you need to do:
1. Make sure the user have remote access privileged in that databse. 
2.   import the  using MySql.Data.MySqlClient;  from Project --> Add Referecne --> select Mysql data and click ok
3.  Add the line  using MySql.Data.MySqlClient;
4. Now use following connection string 
string MyConString = "SERVER=localhost;" +
"DATABASE=mydatabase;" +
"UID=testuser;" +
"PASSWORD=testpassword;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = "select * from mycustomers";
connection.Open();
Reader = command.ExecuteReader();
while (Reader.Read()){ string thisrow = "";
	for (int i= 0;i	 	thisrow+=Reader.GetValue(i).ToString() + ",";
}
connection.Close();		}
 
No comments:
Post a Comment