Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void LoadingData()
- {
- string connString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=ContohLocalDb.mdf;Integrated Security=True";
- try
- {
- SqlConnection connection = new SqlConnection(connString);
- connection.Open();
- Console.WriteLine("State: {0}", connection.State);
- Console.WriteLine("ConnectionString: {0}", connection.ConnectionString);
- MessageBox.Show("Sip, konek kang");
- SqlCommand command = new SqlCommand("SELECT * FROM TableLagu", connection);
- SqlDataAdapter adapter = new SqlDataAdapter(command);
- DataTable table = new DataTable();
- adapter.Fill(table);
- dataGridView1.DataSource = table;
- }
- catch (Exception ex)
- {
- Console.WriteLine("Failed to Connect::" + ex.Message);
- MessageBox.Show("Wah, erro bro");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment