
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 1.04 KB | hits: 13 | expires: Never
Using MySQL With Visual Studio C# Error
string MySqlConnectionValues = "SERVER=blahblahblah.000webhost.com; DATABASE=dbdbdbdb;UID=OopsIDon'tRemember; PASSWORD=whatspassword?;";
MySqlConnection MySQLCon;
MySqlDataAdapter MySQLDataAdapter;
DataTable DTItems;
private void MySQLForm_Load(object sender, EventArgs e)
{
try
{
MySQLCon = new MySqlConnection(MySqlConnectionValues);
}
catch (Exception UnableToConnectToMYSQL)
{
MessageBox.Show(UnableToConnectToMYSQL.Message.ToString());
}
}
DataTable GetAllItems()
{
try
{
string Query = "select * from items";
MySQLDataAdapter = new MySqlDataAdapter(Query, MySQLCon);
DataSet DS = new DataSet();
MySQLDataAdapter.Fill(DS);
return DS.Tables[0];
}
catch (Exception UnableToGetAllItems)
{
MessageBox.Show(UnableToGetAllItems.Message.ToString());
return null;
}
}