cmore
March 13th, 2005, 04:06 PM
I'm have a problem with a find button. Here is my code for the button
private void btnFind_Click(object sender, System.EventArgs e)
{
try
{
this.oleDbDataAdapter1.SelectCommand.CommandText =
"SELECT * FROM Table1 WHERE firstname = "+ this.txtFirstName.Text;
//clear the dataset from the last operation
dataSet11.Clear();
this.oleDbDataAdapter1.Fill(this.dataSet11.Tables["Table1"]);
}
catch(System.Data.OleDb.OleDbException exp)
{
MessageBox.Show(exp.ToString());
}
//copy the dataset in datatable object
DataTable dataTable = dataSet11.Tables[ 0 ];
//if the row count = 0 then the qurey return nothing
if ( dataTable.Rows.Count == 0 )
MessageBox.Show("Record not founded");
}
The error im getting is
System.Data.OleDb.OleDbExepetion: No value given one or more required parameters.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(int32hr)
at Sytem.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResults)
***bunch more things like this***
and the last line says this
at windowsApplication4.Form1.btnFind_Click(Object sender, EventArgs e) in C:\documents and settings\owner\my documents\visual studio projects\windowsapplication4\windowsaplication4\form1.cs : line 294
Ok the line 294 is:
this.oleDbDataAdapter1.Fill(this.dataSet11.Tables["Table1"]);
If any one can help thanks
private void btnFind_Click(object sender, System.EventArgs e)
{
try
{
this.oleDbDataAdapter1.SelectCommand.CommandText =
"SELECT * FROM Table1 WHERE firstname = "+ this.txtFirstName.Text;
//clear the dataset from the last operation
dataSet11.Clear();
this.oleDbDataAdapter1.Fill(this.dataSet11.Tables["Table1"]);
}
catch(System.Data.OleDb.OleDbException exp)
{
MessageBox.Show(exp.ToString());
}
//copy the dataset in datatable object
DataTable dataTable = dataSet11.Tables[ 0 ];
//if the row count = 0 then the qurey return nothing
if ( dataTable.Rows.Count == 0 )
MessageBox.Show("Record not founded");
}
The error im getting is
System.Data.OleDb.OleDbExepetion: No value given one or more required parameters.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(int32hr)
at Sytem.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResults)
***bunch more things like this***
and the last line says this
at windowsApplication4.Form1.btnFind_Click(Object sender, EventArgs e) in C:\documents and settings\owner\my documents\visual studio projects\windowsapplication4\windowsaplication4\form1.cs : line 294
Ok the line 294 is:
this.oleDbDataAdapter1.Fill(this.dataSet11.Tables["Table1"]);
If any one can help thanks