Problem Reading Access

Hello,

I wrote a code for reading data from Microsoft Access file but it gives me the following error:
No value given for one or more required parameters.

Here is the code

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();
}
}
}

at this line:

dread = comm.ExecuteReader();

Can you tell me what the problem is?

Regards,
XCoder
[3230 byte] By [xCoder] at [2007-11-20 10:05:09]
# 1 Re: Problem Reading Access
Dont do SQLs like that.. Look up a what a parameterized query is..
cjard at 2007-11-10 3:29:54 >