boysilent
پنج شنبه 27 مهر 1391, 11:23 صبح
سلام دوستان عزیز من این کد رو نوشتم ولی چیزی در پایگاه درج نمیشه البته پیام با موفقیت درج شد نشان داده میشه ؟؟
if (txtdate.Text != "" && txtalireza.Text != "" && txtdatekamel.Text != "" && txthasan.Text != "" && txtkarbar.Text != "" && txtkarkard.Text != "" && txtkharid.Text != "" && txtmoj.Text != "" && txttozih.Text != "")
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\Resources\dbcn.mdf;Integrated Security=True;User Instance=True");
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText="INSERT INTO newbuy(byname,datekol,dateshort,karkard,kharidha,b arali,barhasan,barmoj,descrip)VALUES(@byname,@date kol,@dateshort,@karkard,@kharidha,@barali,@barhasa n,@barmoj,@descrip)";
com.Parameters.AddWithValue("@byname",txtkarbar.Text);
com.Parameters.AddWithValue("@datekol", txtdatekamel.Text);
com.Parameters.AddWithValue("@dateshort", txtdate.Text);
com.Parameters.AddWithValue("@karkard",txtkarkard.Text);
com.Parameters.AddWithValue("@kharidha",txtkharid.Text);
com.Parameters.AddWithValue("@barali",txtalireza.Text);
com.Parameters.AddWithValue("@barhasan",txthasan.Text);
com.Parameters.AddWithValue("@barmoj",txtmoj.Text);
com.Parameters.AddWithValue("@descrip",txttozih.Text);
con.Open();
com.ExecuteNonQuery();
MessageBox.Show("کاربر گرامی ثبت با موفقیت انجام شد","پیغام سیستم");
con.Close();
}
else
{ MessageBox.Show("کاربر گرامی لطفا تمامی فیلد هارا پرکنید", "خطای سیستم"); }
2/ میخواستم وقتی روی یه سطر از گرریدویو کلیک شد اگه نال بود پیام صادر بشه و پنجره بساه نشه
من ادامه این کدو میگم:
datagreid1.Rows??? !=null;
if (txtdate.Text != "" && txtalireza.Text != "" && txtdatekamel.Text != "" && txthasan.Text != "" && txtkarbar.Text != "" && txtkarkard.Text != "" && txtkharid.Text != "" && txtmoj.Text != "" && txttozih.Text != "")
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\Resources\dbcn.mdf;Integrated Security=True;User Instance=True");
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText="INSERT INTO newbuy(byname,datekol,dateshort,karkard,kharidha,b arali,barhasan,barmoj,descrip)VALUES(@byname,@date kol,@dateshort,@karkard,@kharidha,@barali,@barhasa n,@barmoj,@descrip)";
com.Parameters.AddWithValue("@byname",txtkarbar.Text);
com.Parameters.AddWithValue("@datekol", txtdatekamel.Text);
com.Parameters.AddWithValue("@dateshort", txtdate.Text);
com.Parameters.AddWithValue("@karkard",txtkarkard.Text);
com.Parameters.AddWithValue("@kharidha",txtkharid.Text);
com.Parameters.AddWithValue("@barali",txtalireza.Text);
com.Parameters.AddWithValue("@barhasan",txthasan.Text);
com.Parameters.AddWithValue("@barmoj",txtmoj.Text);
com.Parameters.AddWithValue("@descrip",txttozih.Text);
con.Open();
com.ExecuteNonQuery();
MessageBox.Show("کاربر گرامی ثبت با موفقیت انجام شد","پیغام سیستم");
con.Close();
}
else
{ MessageBox.Show("کاربر گرامی لطفا تمامی فیلد هارا پرکنید", "خطای سیستم"); }
2/ میخواستم وقتی روی یه سطر از گرریدویو کلیک شد اگه نال بود پیام صادر بشه و پنجره بساه نشه
من ادامه این کدو میگم:
datagreid1.Rows??? !=null;