473,503 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Helper function in page_load sub; resultset from SqL

I'm kind of new to asp.net from classic asp, I need to get records/
fields from a resultset to display on aspx page (no datalist,
repeater, or datagrid):
<script runat="server">

Sub Page_Load(Sender As Object, E As EventArgs)
dim strConnection as SQLConnection
dim objCommand as SQLCommand
Dim objDataReader As SQLDataReader
strConnection = New SqlConnection("Data Source=myserver.net;Initial
Catalog=thedb;User Id=me;Password=you;")
objCommand = New SqlCommand( "select cbid,name,category from
cardbanners where grouping = '468A'", strConnection)
strConnection.Open()
objDataReader = objCommand.ExecuteReader()
''what data object do i store the resulset from objCommand?
DataSource = objDataReader
DataBind()
objDataReader.Close
strConnection.Close
End Sub

</script>
''''''''''
I want to take, for examplfe, a field 'dbo.caredbanners.category' from
my resultset and put it into a function (based on an user entered name
via request.querystring, or a condition on date object) that i can
simply call <%# mycategoryfunc%on my aspx
Thanks in advance, Ed

Jun 27 '07 #1
1 1539
On Jun 27, 8:01 am, 2...@cox.net wrote:
I'm kind of new to asp.net from classic asp, I need to get records/
fields from a resultset to display on aspx page (no datalist,
repeater, or datagrid):
<script runat="server">

Sub Page_Load(Sender As Object, E As EventArgs)
dim strConnection as SQLConnection
dim objCommand as SQLCommand
Dim objDataReader As SQLDataReader
strConnection = New SqlConnection("Data Source=myserver.net;Initial
Catalog=thedb;User Id=me;Password=you;")
objCommand = New SqlCommand( "select cbid,name,category from
cardbanners where grouping = '468A'", strConnection)
strConnection.Open()
objDataReader = objCommand.ExecuteReader()
''what data object do i store the resulset from objCommand?
DataSource = objDataReader
DataBind()

objDataReader.Close
strConnection.Close
End Sub

</script>
''''''''''
I want to take, for examplfe, a field 'dbo.caredbanners.category' from
my resultset and put it into a function (based on an user entered name
via request.querystring, or a condition on date object) that i can
simply call <%# mycategoryfunc%on my aspx
Thanks in advance, Ed

Hi,

here is a step by step procedure...

http://www.aspfree.com/c/a/Database/...ataReader-2/2/

Thanks
Masudur
http://munnacs.110mb.com
Jun 27 '07 #2

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

Similar topics

2
8545
by: Christian Ista | last post by:
Hello, I have a class. I create an instance of this class in Page_Load event. Somewhere in the page I'd like to execute an a function (public) member of this class. This function return a...
2
1877
by: Chumley the Walrus | last post by:
I'm using a subroutine/helper function display an image (the image would be displayed inside a datalist control's <itemtemplate> ) <script language="VB" runat="server"> Public Sub...
4
4271
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
2
1489
by: Chumley the Walrus | last post by:
I'm using a subroutine/helper function display an image (the image would be displayed inside a datalist control's <itemtemplate> ) <script language="VB" runat="server"> Public Sub...
10
24036
by: bienwell | last post by:
Hi, I have a question about file included in ASP.NET. I have a file that includes all the Sub functions (e.g FileFunct.vb). One of the functions in this file is : Sub TestFunct(ByVal...
8
5716
by: Joe Johnston | last post by:
I need a Browser Helper object written in VB.NET Please point me at a good example. Joe MCPx3 ~ Hoping this MSDN ng three day turnaround is true. Additional info: What is a BHO? In its...
4
2976
by: D. Shane Fowlkes | last post by:
Up until now, I've always had my functions return integers, strings, or booleans. Now, I've (hopefully) written a function to return a 2 column, single row datareader. Assuming I did this...
3
2502
by: thecoolone | last post by:
I am trying to call a function from "a href" inside the same page. this is the code: echo "<br><br><a href=\"isearch($query)\">More results from Mysite</a>"; // calling the function isearch ...
3
1301
by: 276q | last post by:
I'm trying to display header text in my repeater control on a condition if a record exists in my resultset. I cannot get 'cat' to display the "category" record from my resultset (the delimiters are...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.