last day (15 days later) » 

5:40 PM
1
A: How to submit a asp.net page for search using stored procedure

Mohamad shiralizadehI you can Redirect any one who click on btnSearch to current page with some Query Strings. and then in Page_Load you call Search function that reads Query Strings and bind rptSearchResult. I hope you get what I mean... string cString; SqlConnection Conn; string sqlCode = ""; string strGender = "...

 
Thank you. I will try it out.
I don't want to call Search() if it's the first time loading :/
One thing, the URL changes, but the DropDownList sets everything back to default which I don't want. Also, I would like to call SEARCH() only if I clicked Search in the page.
 
for first time: you should check queryStrings, if there isn't any so don't call Search. for set DropDownLists you should check queryString in Page_Load too and decide to choose one option upon queryStrings data
 
Will this do? if (Request.QueryString["provider"] != "")
 
if (Request.QueryString["provider"] != null && Request.QueryString["provider"] != "") is better
 
Do you know how I can prevent the DropDown to reset to default?
 
5:40 PM
you mean that select first item?
 
jsfiddle.net/w5wf6sz1 (I modified it based on what your said, now it just refreshes the page with the URL but doesn't perform the search.
Hi Mohamad
 
My Stored Procedure seems to return no result
:/
Can I show you my Stored Procedure?
 
yes
put it here
 
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[searchPhysician]
(
@strProvider varchar(200),
@strSpecialty varchar(200),
@strLocation varchar(200),
@strGender varchar(20),
@strInsurance varchar(200),
@strLanguage varchar(200)
)

AS

BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
Pretty much what I am looking to do is send a wildcard(%) if the selection wasn't changed so it will search for ALL
Here is my CSHARP
string cString;
SqlConnection Conn;
string sqlCode = "";
string strGender = "";
int rowCount = 0;
string strProv, strSpec, strLoca, strGend, strInsu, strLang;

protected void Page_Load(object sender, EventArgs e)
{
cString = ""; //connection string
if (!Page.IsPostBack)
{
PopulatePhysician();
PopulateLocation();
PopulateSpecialty();
PopulateInsurance();
PopulateLanguage();

if (Request.QueryString["name"] != null && Request.QueryString["name"] != "")
{
Search();
}
}
else {

}
}
/*protected void Page_Unload(object sender, EventArgs e)
I am only testing it out on the PROVIDER dropdown only
<div class="col span_1_of_3_cust">
<div class="brClear setLeft">
<div class="setBold brClear">Select a Provider:</div>
<asp:DropDownList ClientIDMode="Static" ID="ddlProvider" CssClass="setProvDDStyle" runat="server" AppendDataBoundItems="true"></asp:DropDownList>
</div>
<div class="smallPadTop brClear setRight">
<asp:LinkButton ID="lbJP" ClientIDMode="Static" CssClass="defaultLinks" runat="server" OnClick="lbJP_Click">Search</asp:LinkButton>
</div>
<div class="smallPadTop brClear setRight">
<hr class="hrDivider" />
 
5:44 PM
sir its hard to read all of this..
 
How would you like me to send u
 
if you exec your sp with empty texts, does it return any thing?
 
ERROR: Procedure or function 'searchPhysician' expects parameter '@strProvider', which was not supplied.
 
put you exec code here
put your exec code here
 
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[searchPhysician]
(
@strProvider varchar(200),
@strSpecialty varchar(200),
@strLocation varchar(200),
@strGender varchar(20),
@strInsurance varchar(200),
@strLanguage varchar(200)
)

AS

BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
 
5:48 PM
no
how you exec you sp?
using C#
?
 
using (SqlConnection scCon = new SqlConnection(cString))
{
using (SqlCommand scCmd = new SqlCommand("searchPhysician", scCon))
{
SqlDataReader reader;
SqlDataAdapter sda = new SqlDataAdapter();
DataTable dt = new DataTable();
scCmd.CommandType = CommandType.StoredProcedure;

scCmd.Parameters.Add("@strProvider", SqlDbType.VarChar).Value = strProv;
scCmd.Parameters.Add("@strSpecialty", SqlDbType.VarChar).Value = strSpec;
scCmd.Parameters.Add("@strLocation", SqlDbType.VarChar).Value = strLoca;
scCmd.Parameters.Add("@strGender", SqlDbType.VarChar).Value = strGend;
 
do you have teamviewer?
 
I have join.me
 
what is it?
 
5:53 PM
I try to connect to this.
sorry sir its hard to help this way
I try to find an anwser online like this..
bye bro..
 
I think I am doing my calling the wrong way
 
6:07 PM
The URL
is changed but in this code, the ELSE kicks off:
if (Request.QueryString["name"] == "Any Provider")
{
strProv = "%";
}
else
{
strProv = ddlProvider.SelectedItem.Text;
}
for the SEARCH() function
any idea why?
 
put your url..
 
When the SEARCH() is called the URL in the browser still haven't changed
maybe that's why?
I put a breakpoint in the SEARCH function and while it is going through the step... the URL is still the same and didn't have the query string added to it.
Only when the page reloads does the URL change...
 
6:46 PM
redirect code is just in btn_click?
 

last day (15 days later) »