Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 1.04 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Using MySQL With Visual Studio C# Error
  2. string MySqlConnectionValues = "SERVER=blahblahblah.000webhost.com; DATABASE=dbdbdbdb;UID=OopsIDon'tRemember; PASSWORD=whatspassword?;";
  3.     MySqlConnection MySQLCon;
  4.     MySqlDataAdapter MySQLDataAdapter;
  5.     DataTable DTItems;
  6.  
  7.             private void MySQLForm_Load(object sender, EventArgs e)
  8.     {
  9.         try
  10.         {
  11.             MySQLCon = new MySqlConnection(MySqlConnectionValues);
  12.         }
  13.         catch (Exception UnableToConnectToMYSQL)
  14.         {
  15.             MessageBox.Show(UnableToConnectToMYSQL.Message.ToString());
  16.         }
  17.     }
  18.  
  19.     DataTable GetAllItems()
  20.     {
  21.         try
  22.         {
  23.             string Query = "select * from items";
  24.  
  25.             MySQLDataAdapter = new MySqlDataAdapter(Query, MySQLCon);
  26.             DataSet DS = new DataSet();
  27.             MySQLDataAdapter.Fill(DS);
  28.             return DS.Tables[0];
  29.         }
  30.         catch (Exception UnableToGetAllItems)
  31.         {
  32.             MessageBox.Show(UnableToGetAllItems.Message.ToString());
  33.             return null;
  34.         }
  35.     }