473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

asp:SqlDataSource with parameters

I just want to select records with a certain date field today's date:

<asp:SqlDataSource ID="src1" runat="server" ConnectionString="<%$
ConnectionStrings:xyz %>"

SelectCommand="SELECT * FROM [Events] WHERE [Startdate] ? "
OnSelected="src1_Selected">

<SelectParameters>

<asp:Parameter Name="Startdate" Type="DateTime" />

</SelectParameters>

</asp:SqlDataSource>

---------------------

protected void srcEvents_Selected(object sender,
SqlDataSourceStatusEventArgs e)

{

e.Command.Parameters["Startdate"].Value = DateTime.Today;

}

-------------------

I have a list control bind to this data source but when executed the list
doesn't show. That means no record is selected. I know there are
qualifying records since I input them myself in SQL server.

Am newbie so I must code something wrong. Any insignt appreciated.


Nov 10 '07 #1
1 1757
The problem is that the Selected event does not occur until *after* data has
been retrieved from the database. Try setting the parameter in the PageLoad
handler.

--
Robert Dunlop
----------------
http://www.directxzone.org
http://rdunlop.spaces.live.com/
Microsoft DirectX MVP 1998-2006

"E. Kwong" <ekwong999AThotmail.comwrote in message
news:uh**************@TK2MSFTNGP04.phx.gbl...
>I just want to select records with a certain date field today's date:

<asp:SqlDataSource ID="src1" runat="server" ConnectionString="<%$
ConnectionStrings:xyz %>"

SelectCommand="SELECT * FROM [Events] WHERE [Startdate] ? "
OnSelected="src1_Selected">

<SelectParameters>

<asp:Parameter Name="Startdate" Type="DateTime" />

</SelectParameters>

</asp:SqlDataSource>

---------------------

protected void srcEvents_Selected(object sender,
SqlDataSourceStatusEventArgs e)

{

e.Command.Parameters["Startdate"].Value = DateTime.Today;

}

-------------------

I have a list control bind to this data source but when executed the list
doesn't show. That means no record is selected. I know there are
qualifying records since I input them myself in SQL server.

Am newbie so I must code something wrong. Any insignt appreciated.


Nov 10 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alain Hogue | last post by:
When I try to use "%" with the LIKE command it return nothing if they are an acute charater in the search string. For example if I have a field named "Title" containing words like "Hébert, Gagné,...
2
by: alain.hogue | last post by:
I have a table "tblCards" with a field "Titre" that contain french words (Hébert, Gagné, Hélène, etc....) in an database with SQLEXPRESS 2005. I have used the asp:SqlDataSource to filter the...
1
by: Arne Garvander | last post by:
How do I set parameters from code for a SqlDataSource? -- Arne Garvander (I program VB.Net for fun and C# to get paid.)
11
by: tbh | last post by:
is it possible in the ConnectionString of an asp:SqlDataSource construction to refer to a variable i define at the top of my ASPX script and initialize, for example, during Page_Init()? (the...
4
by: saturnius | last post by:
Hello, I have to save the data from a gridview as XML file. The code is shown below. Is there no easier way? I would like to access either asp:SqlDataSource (me.SqlDataSource1.something) or...
1
by: Jon Paal | last post by:
how does a querystring value get passed to the selectcommand statement of an asp:SqlDataSource? <asp:SqlDataSource id="propertyDataSource" Runat="Server" ConnectionString="<%$...
6
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... I'm trying to implement roles in various components (i.e. using different sets of configuration depending, in this case, on which environment your in). Pretty easy to add an AppSettings...
6
by: joehaxor | last post by:
My question is: How do I keep the page from auto querying on page load. I have a ASP:SqlDataSource bound to a Repeater. This repeater replicates tables beneath a search form. The Search form...
4
by: jpchenot | last post by:
Hi guys. When executing the following code, i get this error: Microsoft VBScript runtime error '800a01b6' Object doesn't support this property or method: 'sqlRegistrantUser.Paratemers' ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.