Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 23rd, 2006, 09:35 AM
Registered User
 
Join Date: Nov 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Quesetion about search and SQL data control

Hi folks.. I asked this question in the Visual Studio forum, but no reply yet, and it's not that busy over there, so I'm going to repeat the question here. I hope that's ok, as I need an answer bad!

Here it is:
----------------------------------------------------------------------
I have a page.. that has a form with form fields that I'll pass the names of these fields as variables using the query string.. Or at least that's my plan.. On page 2 which I want to receive the query string variables, I want to use a grid control to show
all of the found records.. and I was going to use a SQL Datasource control.. with SP's for updates, deletes, inserts, etc.. SP's period for that matter, but I'm wondering if I have to use a Paramater in the TSQL to do so? If I do, then can I pass the value of the form query string variables to the parameter? If I can, can I do so using the wizzards, etc, ? I mean I want to just drag the Grid control on the second page, and use the SQL datasource control to pick out the SP's? It seems logical, but I dont' have the time to try it yet, and thought I'd ask before I do since I'm so limited on time, I don't get to play with these sort of problems much any more!

I thought I'd design the same SP's in Visual DB express which I just love.. Beats the heck out of Access! I don't even see the reason for it now, but that's another subject..
Thank you in advance for you're time!
Tim / AKA HoosierDaddy! (Pronounced Whos ur Daddy, and taken from the fact that I'm from Indiana where folks are called "Hoosiers".. which is again pronoucned "Whosur".. in case you didn't know..as I get asked this all the time!
Regards
 
Old February 23rd, 2006, 01:29 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Yes, you need a parameter in the stored procedure for the search term.

Once you set up the parameter in the sproc, you can pass it from the SqlDataSource control to the sproc with a QueryString parameter:
Code:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
  ConnectionString="<%$ ConnectionStrings:DefaultConnectionString %>" 
   SelectCommand="YourSproc" SelectCommandType="StoredProcedure">
  <SelectParameters>
    <asp:QueryStringParameter Name="SearchTerm" 
       QueryStringField="SearchTerm" Type="String" />
  </SelectParameters>
</asp:SqlDataSource>
This code looks at a query string parameter called SearchTerm.

The SqlDataSource has a CancelSelectOnNullParameter property, which by default is set to True, that prevents the data source from executing its Select method when there is no value in the requested query string.

Does this help?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 24th, 2006, 03:19 PM
Registered User
 
Join Date: Nov 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

It does help, but can you tell me how to do so using the VS Express Wizzard? The SQL connection Wizzard? I mean can I do the paramater from there?

Tim
 
Old February 25th, 2006, 05:13 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Just drag the DataSource control on the page, right-click it and choose Configure DataSource.

You'll see a wizards that eventually allows you to choose the parameters....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Granular control in uploading data to SQL 2000 henryoh Excel VBA 2 June 26th, 2006 04:46 PM
Using textbox, button control to search database aad1 C# 4 May 17th, 2006 06:54 PM
SQL search SoC Classic ASP Databases 1 August 20th, 2004 08:52 AM
search select control rajanikrishna HTML Code Clinic 2 March 3rd, 2004 11:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.