السلام عليكم ورحمة الله وبركاته
عندي مشكلة في هذا الكود وهو الكود الذي يسأل عن وجود قيمة سابقا في قاعدة البيانات
OleDbCommand cmdd = new OleDbCommand();
cmdd.CommandType = CommandType.Text;
cmdd.CommandText = " Select * from bookdata where BookCode = '" + bookCodeTextBox.Text + "'";
cmdd.Connection = conn;
if (cmdd.Connection.State != ConnectionState.Open)
cmdd.Connection.Open();
OleDbDataReader dr = cmdd.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
MessageBox.Show("عفواً , لقد وجدنا كتاب يحمل نفس الرقم الكودي المراد تسجيل الكتاب به يرجي ادخال رقم كودي اخر واعادة المحاولة.. وشكراً __ ", "خطاً", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
}
else
{
goto AddCode;
}
dr.Close();
dr.Dispose();
cmdd.Dispose();المشكلة في السطر
cmdd.Connection = conn;
حيث يذع خط احمر تحت conn ورسالة الخطأ هي
Error 1 Cannot use local variable 'conn' before it is declared. The declaration of the local variable hides the field
رجاء المساعدة
وشكراً


