PDA

View Full Version : تکمیل کد update



RIG000
دوشنبه 07 تیر 1389, 20:22 عصر
public static void UpDate(string Etesal, string StrSql)
{
OleDbConnection con = new OleDbConnection(Etesal);
con.Open();
OleDbCommand Cmd = new OleDbCommand(StrSql, con);
try
{
Cmd.ExecuteNonQuery();
MessageBox.Show("اطلاعات مورد نظر ویرایش شد", "ویرایش کردن");
}
catch
{
MessageBox.Show("خطا در ویرایش کردن اطلاعات", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
con.Close();
}


این کد update که تو کلاس تعریف شده .
حالا من توی فرمم میخام اصلاعاتم رو update کنم اطلاعات update نمیشه از دوستان میخام اینو بردارن تو کلاس بزارن و یه کد update بنویسن و نمونه کار بزارن خیلی ممنون میشم.


s2 = "update kala set codekala=" + txtcodekala + "',namekala='" + txtnamekala_update.Text + "',vahed='" + cmbvahed_update.Text + ",ghymatekh=" + txtghimatekh_update.Text + ",ghymatfo=" + txtghymatfo_update.Text + "',tozihat='" + txttozihatkala_update.Text + "' where codekala=" + txtcodekala.Text + "";
// string s = "update groh set kod=" + textBox1.Text + ",gmozohi='" + textBox2.Text + "' where kod=" + textBox1.Text + "";
// string s = "update groh set kod=" + textBox1.Text + ",gmozohi='" + textBox2.Text + "' where kod=" + textBox1.Text + "";
db.UpDate(variables.connectionstring, s2);
// Payegah.ShowData(Variables.masir, Variables.StrCommandGroh, 2, grid);
cleanupdate ();
// s2 = "update kala set codekala='" + txtcodekala + "',namekala='" + txtnamekala_update.Text + "',vahed='" + cmbvahed_update.Text + ",ghymatekh=" + txtghimatekh_update.Text + ",ghymatfo=" + txtghymatfo_update.Text + "',tozihat='" + txttozihatkala_update.Text + "' where codekala=" + txtcodekala .Text + "";
/* s3 = string.Format("insert into kala values( {0},'{1}','{2}',{3},{4},'{5}')",txtcodekala , txtnamekala_update .Text, cmbvahed_update .Text, txtghimatekh_update .Text, txtghymatfo_update.Text, txttozihatkala_update .Text);
// s4 = "update kala set codekala='" + +txtnamekala_update.Text + "',vahed='" + cmbvahed_update.Text + "',ghymatkh='" + txtghimatekh_update.Text + "',ghymatfo='" + txtghymatfo_update.Text + "',tozihat='" + txttozihatkala_update.Text + "";
cleanupdate ();

db.UpDate(variables.connectionstring, s2);
///////////////////////////////////////////////////////////
OleDbConnection con = new OleDbConnection(variables.connectionstring );
con.Open();
OleDbCommand Cmd = new OleDbCommand(s3, con);
try
{
Cmd.ExecuteNonQuery();
}
catch
{
// OleDbCommand Command = new OleDbCommand(s2, con);
// Command.ExecuteNonQuery();
}
con.Close();

cleanupdate ();*/
}

البته همین کد نوشته شده من خاستم از این استفاده کنم اگه همیتون نمونه کار بدین ممنون میشم . نمی دونم چرا مشکل میگیره !!!!!!!!!!!!1

RIG000
دوشنبه 07 تیر 1389, 20:23 عصر
public int x, xx, y;
public string s, s2, s3, s4;