الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

التعديل والحذف لا يعمل

بدأه كارم سامي في 23 فبراير 2014 · 3 رد · 389 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

 

هذا كود الحفظ وهو يعمل جيداً

//insert code
      
            string JSS_connetionString004 = null;
            OleDbConnection JSS_connection004;
            OleDbDataAdapter JSS_oledbAdapter004 = new OleDbDataAdapter();
            string JSS_sql004 = null;
            JSS_connetionString004 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/je_salestoredb.mdb;Persist Security Info=True;Jet OLEDB:Database Password=JE2014";
            JSS_connection004 = new OleDbConnection(JSS_connetionString004);
            JSS_sql004 = "insert into control_room(coroom_ID,coroom_OPERATION,coroom_EMPLOYEE,coroom_USER,coroom_INVOICE_NUM,coroom_SUPPLIER,coroom_CUSTOMER,coroom_USER_CHANGE,coroom_DATE,coroom_TIME,coroom_STATUS) values('" + JSS_str_control_room_ID2 + "','" + JSS_coroom_OPERATION + "','" + JSS_coroom_EMPLOYEE + "','" + JSS_coroom_USER + "','" + JSS_coroom_INVOICE_NUM + "','" + JSS_coroom_SUPPLIER + "','" + JSS_coroom_CUSTOMER + "','" + JSS_coroom_USER_CHANGE + "','" + JSS_coroom_DATE + "','" + JSS_coroom_TIME + "','" + JSS_coroom_STATUS + "')";
            try
            {

                JSS_connection004.Open();
                JSS_oledbAdapter004.InsertCommand = new OleDbCommand(JSS_sql004, JSS_connection004);
                JSS_oledbAdapter004.InsertCommand.ExecuteNonQuery();

            }
            catch (Exception ex)
            {

            }

ام اكودا التعديل و الحذف فلا تعمل مع ان الكود يُنفذ بدون ظهور اخطاء وتظهر رسالة تفيد بأنه تم التعديل

//edit
            string JSS_connetionString011 = null;
            OleDbConnection JSS_connection011;
            OleDbDataAdapter JSS_oledbAdapter011 = new OleDbDataAdapter();
            string JSS_sql011 = null;
            JSS_connetionString011 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/je_salestoredb.mdb;Persist Security Info=True;Jet OLEDB:Database Password=JE2014";
            JSS_connection011 = new OleDbConnection(JSS_connetionString011);
            JSS_sql011 = "update product_companies set prodc_NAME = '" + textBox1.Text + "',prodc_BARCODE = '" + textBox2.Text + "' where prodc_ID = '" + label3.Text + "'";

            try
            {
                JSS_connection011.Open();
                JSS_oledbAdapter011.UpdateCommand = JSS_connection011.CreateCommand();
                JSS_oledbAdapter011.UpdateCommand.CommandText = JSS_sql011;
                JSS_oledbAdapter011.UpdateCommand.ExecuteNonQuery();
                MessageBox.Show("تم تعديل البيانات", "تم التعديل", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
string JSS_connetionString001 = null;
            OleDbConnection JSS_connection001;
            OleDbDataAdapter JSS_oledbAdapter001 = new OleDbDataAdapter();
            string JSS_sql001 = null;
            JSS_connetionString001 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/je_salestoredb.mdb;Persist Security Info=True;Jet OLEDB:Database Password=JE2014";
            JSS_connection001 = new OleDbConnection(JSS_connetionString001);
            JSS_sql001 = "delete from product_companies where prodc_ID = '" + label3.Text + "'";
            try
            {
                JSS_connection001.Open();
                JSS_oledbAdapter001.DeleteCommand = JSS_connection001.CreateCommand();
                JSS_oledbAdapter001.DeleteCommand.CommandText = JSS_sql001;
                JSS_oledbAdapter001.DeleteCommand.ExecuteNonQuery();
                MessageBox.Show("تم حذف المجموعة", "تم الحذف", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

رجاء المساعدة

#2

try to write the where condition like this  (prodc_ID ="+label3.text+")  without single quotation 


#3
srss1985 كتب:

 

try to write the where condition like this  (prodc_ID ="+label3.text+")  without single quotation 

 

 

للأ سف لا يعمل

#4

جرب هذا الكود

//update
string JSS_connetionString004 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/je_salestoredb.mdb;Persist Security Info=True;Jet OLEDB:Database Password=JE2014";            
OleDbConnection JSS_connection004=new OleDbConnection(JSS_connetionString004);
string JSS_sql004 = "update product_companies set prodc_NAME = '" + textBox1.Text.ToString() + "' , prodc_BARCODE = '" + textBox2.Text.ToString() + "' where prodc_ID = '" + label3.Text.ToString() + "'";
OleDbCommand JSS_Command004= new OleDbCommand(JSS_sql004, JSS_connection004);
try 
{
	JSS_connection004.Open();
	JSS_Command004.ExecuteNonQuery();
	MessageBox.Show("تم تعديل البيانات", "تم التعديل", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);

 }
catch (Exception ex)
{
	MessageBox.Show(ex.Message.ToString(), "Warning Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
	JSS_connection004.Close();
}
////////////////////////////////////////
//delete
string JSS_connetionString001 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/je_salestoredb.mdb;Persist Security Info=True;Jet OLEDB:Database Password=JE2014";            
OleDbConnection JSS_connection001=new OleDbConnection(JSS_connetionString001);
string JSS_sql001 =  "delete from product_companies where prodc_ID = '" + label3.Text.ToString() + "'";
OleDbCommand JSS_Command001= new OleDbCommand(JSS_sql001, JSS_connection001);
try 
{
	JSS_connection001.Open();
	JSS_Command001.ExecuteNonQuery();
	MessageBox.Show("تم حذف المجموعة", "تم الحذف", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
}
catch (Exception ex)
{
	MessageBox.Show(ex.Message.ToString(), "Warning Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
	JSS_connection001.Close();
}

مواضيع مشابهة