document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. private void LoadingData()
  2.         {
  3.  
  4.             string connString = @"Data Source=(LocalDB)\\v11.0;AttachDbFilename=ContohLocalDb.mdf;Integrated Security=True";
  5.  
  6.             try
  7.             {
  8.                 SqlConnection connection = new SqlConnection(connString);
  9.                 connection.Open();
  10.  
  11.                 Console.WriteLine("State: {0}", connection.State);
  12.                 Console.WriteLine("ConnectionString: {0}", connection.ConnectionString);
  13.                 MessageBox.Show("Sip, konek kang");
  14.  
  15.                 SqlCommand command = new SqlCommand("SELECT * FROM TableLagu", connection);
  16.                 SqlDataAdapter adapter = new SqlDataAdapter(command);
  17.  
  18.                 DataTable table = new DataTable();
  19.  
  20.                 adapter.Fill(table);
  21.  
  22.                 dataGridView1.DataSource = table;
  23.  
  24.             }
  25.             catch (Exception ex)
  26.             {
  27.                 Console.WriteLine("Failed to Connect::" + ex.Message);
  28.                 MessageBox.Show("Wah, erro bro");
  29.             }
  30.         }
');