سلام
از این استفاده کنید:
public void InsertToDB(string _first, string _last, string _tell)
{
SqlConnection cn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirecto ry|\\MyDB.mdf;Integrated Security=True;User Instance=True");
SqlCommand cm = cn.CreateCommand();
cn.Open();
cm.CommandText = "INSERT INTO bank (first,last,tell) VALUES (@first,@last,@tell)";
cm.Parameters.AddWithValue("@first", _first);
cm.Parameters.AddWithValue("@last", _last);
cm.Parameters.AddWithValue("@tell", _tell);
cm.ExecuteNonQuery();
}