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;
}Take the completed srcCmd string, copy it into SQL queryAnalyzer, and execute
it.
You will see what is wrong.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"John Chapman" wrote:
Quote:
Originally Posted by
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;
}
>
Thank you, I actually found that the issue was that the way I was
retrieving the sort expression returned nothing. So it was looking to sort
by a blank field.
"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.yabbadabbadoo.comwrote in
message news:E76C3BF9-193D-4C3D-8923-39A4B1DEED05@.microsoft.com...
Quote:
Originally Posted by
Take the completed srcCmd string, copy it into SQL queryAnalyzer, and
execute
it.
You will see what is wrong.
Peter
>
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
>
>
>
>
"John Chapman" wrote:
>
Quote:
Originally Posted by
>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;
> }
>>
0 comments:
Post a Comment