السلام عليكم
كنت احاول اليوم في عمل برنامج بسيط جدا بحيث استطيع جلب معلومات بالإضافة الى تحديثها. في الجزء من الكود الذي يحاول جلب المعلومات يطلع خطأ في السطر
dread = comm.ExecuteReader();
الخطأ الناتج هو:
No value given for one or more required parameters.
مع العلم ان الكود صحيح و تأكدت من عدة مواقع على النت
الكود كاملا:
String conString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + txtPath.Text + ";Persist Security Info=False";
OleDbConnection dbcon = null;
try
{
dbcon = new OleDbConnection(conString);
String sql = "SELECT s_no,s_name,first,second,result,duration,comp_name,active,success,createfile FROM students WHERE s_no='" + txtNum.Text + "'";
OleDbCommand comm = new OleDbCommand(sql, dbcon);
dbcon.Open();
if (dbcon.State == ConnectionState.Open)
{
OleDbDataReader dread = null;
try
{
comm.CommandType = CommandType.Text;
dread = comm.ExecuteReader();
if (dread.Read())
{
txtNum.Text = dread.GetString(0);
txtName.Text = dread.GetString(1);
txtFirst.Text = dread.GetInt32(2).ToString();
txtSecond.Text = dread.GetInt32(3).ToString();
txtResult.Text = dread.GetInt32(4).ToString();
txtDuration.Text = dread.GetString(5);
txtComp.Text = dread.GetString(6);
chkActive.Checked = dread.GetBoolean(7);
chkSuccess.Checked = dread.GetBoolean(8);
chkCreate.Checked = dread.GetBoolean(9);
}
else
{
MessageBox.Show("Could not find the number provided!", "Search Error");
}
}
/*catch (OleDbException oledbex)
{
MessageBox.Show(oledbex.Message, "Inner DB Error");
}*/
finally
{
if (dread != null)
{
dread.Close();
}
}
}
}
/*catch (OleDbException olex)
{
MessageBox.Show(olex.Message, "DB Error");
}*/
finally
{
if (dbcon != null && dbcon.State == ConnectionState.Open)
{
dbcon.Close();
}
}شاكرا لكم مساعدتكم

