J
John Chapman
Hello, I am using the code down below and I keep receiving the error: No
value given for one or more required parameters.
What am I doing wrong?
protected void dgCustomerSearch_Sort(object sender, EventArgs e)
{
string strCustomerSearchQry;
string strSortExp = dgCustomerSearch.SortExpression.ToString();
strCustomerSearchQry = txtSearchCustomer.Text;
lblCustSrchNotValid.Visible = false;
string srcConString = "Provider=Microsoft.Jet.OleDb.4.0;Data
Source=" + MapPath("cpaneldb.mdb");
OleDbConnection objConString = new OleDbConnection(srcConString);
string srcCmd = "SELECT * FROM tbl_customers WHERE
((tbl_customers.[ID] LIKE '%" + strCustomerSearchQry + "%') OR
(tbl_customers.[LASTNAME] LIKE '%" + strCustomerSearchQry + "%')) ORDER BY
tbl_customers.[" + strSortExp + "]";
objConString.Open();
OleDbCommand objCmd = new OleDbCommand(srcCmd, objConString);
OleDbDataReader objRdr;
objRdr = objCmd.ExecuteReader();
dgCustomerSearch.DataSource = objRdr;
dgCustomerSearch.DataBind();
objRdr.Close();
objConString.Close();
dgCustomerSearch.Visible = true;
}
value given for one or more required parameters.
What am I doing wrong?
protected void dgCustomerSearch_Sort(object sender, EventArgs e)
{
string strCustomerSearchQry;
string strSortExp = dgCustomerSearch.SortExpression.ToString();
strCustomerSearchQry = txtSearchCustomer.Text;
lblCustSrchNotValid.Visible = false;
string srcConString = "Provider=Microsoft.Jet.OleDb.4.0;Data
Source=" + MapPath("cpaneldb.mdb");
OleDbConnection objConString = new OleDbConnection(srcConString);
string srcCmd = "SELECT * FROM tbl_customers WHERE
((tbl_customers.[ID] LIKE '%" + strCustomerSearchQry + "%') OR
(tbl_customers.[LASTNAME] LIKE '%" + strCustomerSearchQry + "%')) ORDER BY
tbl_customers.[" + strSortExp + "]";
objConString.Open();
OleDbCommand objCmd = new OleDbCommand(srcCmd, objConString);
OleDbDataReader objRdr;
objRdr = objCmd.ExecuteReader();
dgCustomerSearch.DataSource = objRdr;
dgCustomerSearch.DataBind();
objRdr.Close();
objConString.Close();
dgCustomerSearch.Visible = true;
}