StrQ = "";
SqlConnection myConn;
SqlCommand myComm;
SqlDataReader myDR;

try
{
StrConn =
"Data Source=.;Initial Catalog=Havapeyma;Integrated Security=True";
StrQ =
"SELECT * FROM [Admin] WHERE (([UserName] = @UserName) AND ([Password] = @Pass))";
myConn =
newSqlConnection(StrConn);
myComm =
newSqlCommand();
myComm.Connection = myConn;
myComm.CommandType =
CommandType.Text;
myComm.CommandText = StrQ;
myComm.Parameters.Add(
"UserName", SqlDbType.NVarChar, 50).Value = this.textBox1.Text;
myComm.Parameters.Add(
"Pass", SqlDbType.NVarChar, 50).Value = this.textBox2.Text;
myConn.Open();
myDR = myComm.ExecuteReader();
if (myDR.Read())
{
Form2 F2 = newForm2();
F2.ShowDialog();
this.Hide();
}
else
{
MessageBox.Show("نام کاربری یا کلمه عبور صحیح نمی باشد","خطا");
textBox1.Text =
""; textBox2.Text = ""; textBox1.Focus();
}
myConn.Close();
}
catch (Exception) { }

زمانی که اجرا میکنم از خط
myConn.Open();
خطا میگیره مینویسه به دیتابیس متصل نیست.
لطفا کمکم کنید
مرسی