Jump to content

merging searches?


zezu10

Recommended Posts

Hi guys, I currently have a web form which searches a SQL table, and fills a datagrid.My form currently has two searches, which I have a seperate textbox and button for each, however I am wanting to add more searches to my form, and therefore am looking for the best way to have just the one textbox and button, but allowing multiple searches?Would a dropdown list be a good way to get around this problem, and if so, what is the best way to exectute that way of working around my current problem?

Link to comment
Share on other sites

the problem I have is that I now have about 7 or 8 searches that I have to do, and am having problems figuring out how to activate different searches with what has been selected by the DDL.I'm filling the grid by doing;

	Sub FillGridReg()		Dim GetDataset As New GeneralReaderQuery(Constants.DATACCESSLINK, _											"STOREDPROCNAME", _											"@au_parameter", _											txtSearch.Text)		Me.GrdVehicles.DataSource = GetDataset.FetchDataSet1Param		GrdVehicles.DataBind()	End Sub

So am I going to have to do various IF statements but also how am I going to change the parameter value when the DDL is select?

Link to comment
Share on other sites

If condition1 Then  FillGridReg("param1")End IfIf condition2 Then  FillGridReg("param2")End IfSub FillGridReg(param As String)		Dim GetDataset As New GeneralReaderQuery(Constants.DATACCESSLINK, _											"STOREDPROCNAME", _											param, _											txtSearch.Text)		Me.GrdVehicles.DataSource = GetDataset.FetchDataSet1Param		GrdVehicles.DataBind()End Sub

Link to comment
Share on other sites

well my searches kinda vary, for example;RegNoChassisNoCustomerNameRegDateAt the moment I have a StoredProc for each search, with each of them passing a specific paramter, ie @au_regdate1 and @au_regno1At the moment I have all the searches working on one form, but that means I currently have 9 text boxes and buttons on my page.It don't look too purdy :/ALSOI have a form working on a webspace, but now when I try to use to it locally, I get a Parser Error?

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Could not load type 'WebApplication1.VehicleSearchForm'.Source Error: Line 1:  <%@ Page Language="vb" AutoEventWireup="false" Codebehind="VehicleSearchForm.aspx.vb" Inherits="WebApplication1.VehicleSearchForm" %>Line 2:  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">Line 3:  <HTML>

Any ideas?

Link to comment
Share on other sites

At the moment I have a StoredProc for each search, with each of them passing a specific paramter, ie @au_regdate1 and @au_regno1At the moment I have all the searches working on one form, but that means I currently have 9 text boxes and buttons on my page.
I have a search form on one of my pages whiches search through help tickets by either Reference #, Date, Email Address, or keyword search of the contents. I also chose the dropdown list route.In my codebehind (C#) I have a switch which detects the selected value of the dropdown list and then tells my search functions (I have more than one...but that doesn't matter) what stored procedure to use. This isn't exactly how I do it - I have a more OOP approach - but this conveys the idea:
string procedure = String.Empty;switch(SearchType.SelectedValue){	case "RefNo":		procedure = "DoSearchByReferenceNumber";		break;	case "Date":		procedure = "DoSearchByDate";		break;	case "Email":		procedure = "DoSearchByEmail";		break;	case "Search":		procedure = "DoSearchByKeyword";		break;}DoSearch(procedure, txtSearch.Text);

Link to comment
Share on other sites

ok I fixed that small error I had, was a simple typo, grrrr.erm I would like to keep my code vb.net based as much as possible, I do understand your code tho, it's just trying to pass the individual storedproc names that I am currently having trouble with.

Link to comment
Share on other sites

Done it. For anyone who has this problem ever...I did it by.

	Sub FillGridCustomerDetails()		Dim MyParams As New ParamProperties		MyParams.ParamName1 = "@au_customername1"		MyParams.ParamVal1 = txtCustomerName.Text		MyParams.ParamName2 = "@au_custadd1"		MyParams.ParamVal2 = txtCustomerAdd1.Text		Dim GetReader As New GeneralReaderQuery(Constants.dataccessname, "storedprocname")		Me.GrdVehicles.DataSource = GetReader.FetchDataSet2Param(MyParams)		Me.GrdVehicles.DataBind()	End Sub

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...