Please look here:
http://msdn.microsoft.com/en-us/library/aa326257(v=VS.71).aspx[
^]. You'll see what you were doing wrong.
private void button1_Click(object sender, EventArgs e)
{
String connectionString = "Data Source=TOSHIBA-PC;Initial Catalog=ACCESSCONTROL;User ID=ABC;Password=hello;MultipleActiveResultSets=True";
con = new SqlConnection(connectionString);
cmd = new SqlCommand(con);
try
{
con.Open();
MessageBox.Show("Connection opened.");
}
catch (SyntaxErrorException a)
{
MessageBox.Show("Error: " + a);
}
finally
{
con.Close();
MessageBox.Show("Connection closed.");
}
}
Best Regards,
—MRB