This message was discovered on ASPFriends.com 'ngfx-sqlclient' list.
| Damian Barrow |
-- Moved from [aspngfreeforall] to [ngfx-sqlclient] by Tim Musschoot <Click here to reveal e-mail address> --
I have two drop down lists, both of which reflect the returns of the same stored procedure. How do I set the droip downs to use the same data?
My code
<%@ Page Language=3D"VB" Debug=3D"true" %> <%@ import Namespace=3D"System.Data" %> <%@ import Namespace=3D"System.Data.SqlClient" %> <%@ outputcache duration=3D"12000" varybyparam=3D"none" %>
<script runat=3D"server">
Sub Page_Load(Sender As Object, E As EventArgs) =20 Dim ConnectionString As String =3D "Data Source=3Dxxx; Initial Catalog=3Dxxx; User ID=3Dxxx; password=3Dxxx" Dim CommandText As String =3D "PollData_getDates" Dim myConnection As New SqlConnection(ConnectionString) Dim myCommand As New SqlCommand(CommandText, myConnection) =20 myCommand.CommandType =3D CommandType.StoredProcedure myConnection.Open() =20 date_list1.DataSource =3D myCommand.ExecuteReader(CommandBehavior.CloseConnection) date_list1.DataBind() 'todo - ask the lists how to make this bit work :D
date_list2.DataSource =3D myCommand.ExecuteReader(CommandBehavior.CloseConnection) date_list2.DataBind() =20 End Sub
</script> <html> <head> </head> <body style=3D"FONT-FAMILY: arial"> <h2>Simple Stored Procedure=20 </h2> <hr size=3D"1" /> <form runat=3D"server"> <asp:DropDownList id=3D"date_list1" runat=3D"server" DataTextField=3D"nice_day" DataValueField=3D"dd_val"></asp:DropDownList> <br> <asp:DropDownList id=3D"date_list2" runat=3D"server" DataTextField=3D"nice_day" DataValueField=3D"dd_val"></asp:DropDownList> </form> </body> </html>
|
|
| |
| |
| Jamie Dearnley |
Hi Damian, Why don't you use a dataset instead of a datareader?
Jamie
[Original message clipped]
|
|
| |
|
| |
| James Avery |
What Error are you getting? If you are going to use it twice you might want to use a dataset, so you only hit the database once.
Dim oAdapter as New SqlDataAdapter(myCommand) Dim dsData as New DataSet() oAdapter.Fill(dsData)
Then just bind to dsData as many times as you want.
-----Original Message----- From: Damian Barrow [mailto:Click here to reveal e-mail address] Sent: Tuesday, July 23, 2002 8:04 AM To: ngfx-sqlclient Subject: [ngfx-sqlclient] Reuse a connection?
-- Moved from [aspngfreeforall] to [ngfx-sqlclient] by Tim Musschoot <Click here to reveal e-mail address> --
I have two drop down lists, both of which reflect the returns of the same stored procedure. How do I set the droip downs to use the same data?
My code
<%@ Page Language=3D"VB" Debug=3D"true" %> <%@ import Namespace=3D"System.Data" %> <%@ import Namespace=3D"System.Data.SqlClient" %> <%@ outputcache duration=3D"12000" varybyparam=3D"none" %>
<script runat=3D"server">
Sub Page_Load(Sender As Object, E As EventArgs) =20 Dim ConnectionString As String =3D "Data Source=3Dxxx; Initial Catalog=3Dxxx; User ID=3Dxxx; password=3Dxxx" Dim CommandText As String =3D "PollData_getDates" Dim myConnection As New SqlConnection(ConnectionString) Dim myCommand As New SqlCommand(CommandText, myConnection) =20 myCommand.CommandType =3D CommandType.StoredProcedure myConnection.Open() =20 date_list1.DataSource =3D myCommand.ExecuteReader(CommandBehavior.CloseConnection) date_list1.DataBind() 'todo - ask the lists how to make this bit work :D
date_list2.DataSource =3D myCommand.ExecuteReader(CommandBehavior.CloseConnection) date_list2.DataBind() =20 End Sub
</script> <html> <head> </head> <body style=3D"FONT-FAMILY: arial"> <h2>Simple Stored Procedure=20 </h2> <hr size=3D"1" /> <form runat=3D"server"> <asp:DropDownList id=3D"date_list1" runat=3D"server" DataTextField=3D"nice_day" DataValueField=3D"dd_val"></asp:DropDownList> <br> <asp:DropDownList id=3D"date_list2" runat=3D"server" DataTextField=3D"nice_day" DataValueField=3D"dd_val"></asp:DropDownList> </form> </body> </html> | [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID | http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT
|
|
| |
|
| |
| Damian Barrow |
>>> Why don't you use a dataset instead of a datareader?
Blank spot. And I have no idea what I'm doing :P Thanks all. Now - I know I should work this out myself but how do I rip out the first 5 rows from dsData?
Cheers Damian
-----Original Message----- From: Jamie Dearnley [mailto:Click here to reveal e-mail address]=20 Sent: 23 July 2002 15:59 To: ngfx-sqlclient Subject: [ngfx-sqlclient] RE: Reuse a connection?
Hi Damian, Why don't you use a dataset instead of a datareader?
Jamie
[Original message clipped]
| [ngfx-sqlclient] member Click here to reveal e-mail address =3D YOUR = ID=20 | http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp =3D JOIN/QUIT
_____________________________________________________________________ Travel Counsellors has scanned this message for all known viruses.
|
|
| |
|
| |
| Jon Ceanfaglione |
This should get you started
DataSet _ds;
foreach(DataTable _dt in _ds.Tables) //loop through tables { foreach(DataRow _dr in _dt.Rows) //loop through rows { for(int i=0;i<_dr.ItemArray.Length;i++)//loop columns { Response.Write(_dr.ItemArray[i].ToString()); } } }
----Original Message----- From: Damian Barrow [mailto:Click here to reveal e-mail address] Sent: Tuesday, July 23, 2002 11:37 AM To: ngfx-sqlclient Subject: [ngfx-sqlclient] RE: Reuse a connection?
>>> Why don't you use a dataset instead of a datareader?
Blank spot. And I have no idea what I'm doing :P Thanks all. Now - I know I should work this out myself but how do I rip out the first 5 rows from dsData?
Cheers Damian
-----Original Message----- From: Jamie Dearnley [mailto:Click here to reveal e-mail address] Sent: 23 July 2002 15:59 To: ngfx-sqlclient Subject: [ngfx-sqlclient] RE: Reuse a connection?
Hi Damian, Why don't you use a dataset instead of a datareader?
Jamie
[Original message clipped]
| [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID | http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT
_____________________________________________________________________ Travel Counsellors has scanned this message for all known viruses.
| [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID | http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT
__________________________________________________
The information contained in this communication is intended only for the use of the recipient named above, and may be legally privileged, confidential and exempt from disclosure under applicable law. If the reader of this communication is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited. If you have received this communication in error, please re-send this communication to the sender and delete the original communication and any copy of it from your computer system. Thank you.
|
|
| |
|
| | |
|
|
|
|