473,836 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Recordset Function

Hi all

I have started writing a web app in Visual Studio 2005 (using c#). I
am new to both C# and Visual Studio 2005.

I will start by telling you what I need and then how I would have done
it using classic ASP previously.

What I need:
- Within Visual Studio 2005 (c#) to create a reusable function within
a file that can essentially be included in all my other pages (IE add
an include file reference from a master page - Please tell me if this
is poor coding practice).
- From my desired page I want to be able to pass a SQL command to a
function contained within the included file. The function then needs
to return a recodset (accessing a SQL database).

How I would do it in classic ASP.
For arguments sake lets say I have a standard ASP file. That page
potentially contained one or more include files. The include files
contain various functions so that I could reuse them within various
other pages (oo or modular coding).

For example:
I had a page where i wanted to display users. I would create a
standard ASP page and then using include file I would reference
functions from the included file(s). Essentially I would parse a SQL
stored procedure and its parameters or a SQL command (in a string
format) from the users page, make a connection and return a recodset.
Then draw the page as per my recordset or required.

How do I do this in C# (within visual studio 2005)?

Please suggest common/best practice methodolgies and teminology.
Providing code examples would be great.

Thanks in advance.

Fabio

Oct 1 '07 #1
2 1927
<fp******@gmail .comwrote in message
news:11******** **************@ d55g2000hsg.goo glegroups.com.. .
How do I do this in ASP.NET / C# (within visual studio 2005)?
Firstly, ASP.NET does not use include files. For reusable markup etc, create
a UserControl. For reusable code, create a class.
http://www.google.co.uk/search?sourc...22+UserControl
http://www.google.co.uk/search?sourc...2C%23%22+class

Secondly, ASP.NET does not use ADO, so you can forget all about Recordsets.
ASP.NET uses ADO.NET.
http://www.google.co.uk/search?sourc...22ADO%2eNET%22

Thirdly, ASP.NET has a whole range of data-aware controls which remove
(almost) all of the tedious looping through rows of data and writing out
tables manually. In the above case, you will almost certainly want to use a
GridView.
http://aspnet101.com/aspnet101/tutorials.aspx?id=51

The above is absolutely fundamental to ASP.NET, so I would respectfully
suggest that you do the following:

1) Forget everything you ever knew about ASP Classic - ASP.NET is completely
different in virtually every way...

2) Get a copy of this:
http://www.amazon.com/Beginning-ASP-...1239485&sr=1-3
and work all of the way through it...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 1 '07 #2
Hi Fabio,

You have quite a learning curve to surmount if you want to use ASP.Net. It
is a completely different programming model from ASP Classic. To begin with,
it is truly and fully object-oriented, not procedural. It does not use COM,
which is a pseudo-object-oriented technology, but the .Net Framework, which
is truly and fully object-oriented. If you've never worked with true OOP, I
suggest that you start by familiarizing yourself with OOP programming
principles. Here's a good place to start:

http://en.wikipedia.org/wiki/Object-...ed_programming

Now, assuming that you're willing to do the work necessary to use ASP.Net,
that is, to study up on the technology and teach yourself a new way of
thinking about programming, here are a few web sites that can help you get
started with ASP.Net:

http://www.asp.net/
http://www.w3schools.com/aspnet/default.asp
http://msdn2.microsoft.com/en-us/asp.net/default.aspx

It is indeed quite a learning curve, and you have the choice of sticking
with Classic ASP. But the rewards for learning and adapting ASP.Net and
object-oriented programming are many. Once you have learned how to leverage
OOP and the ASP.Net design model and practices, you will be able to create
web applications quickly, and manage them much more easily and effectively.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

<fp******@gmail .comwrote in message
news:11******** **************@ d55g2000hsg.goo glegroups.com.. .
Hi all

I have started writing a web app in Visual Studio 2005 (using c#). I
am new to both C# and Visual Studio 2005.

I will start by telling you what I need and then how I would have done
it using classic ASP previously.

What I need:
- Within Visual Studio 2005 (c#) to create a reusable function within
a file that can essentially be included in all my other pages (IE add
an include file reference from a master page - Please tell me if this
is poor coding practice).
- From my desired page I want to be able to pass a SQL command to a
function contained within the included file. The function then needs
to return a recodset (accessing a SQL database).

How I would do it in classic ASP.
For arguments sake lets say I have a standard ASP file. That page
potentially contained one or more include files. The include files
contain various functions so that I could reuse them within various
other pages (oo or modular coding).

For example:
I had a page where i wanted to display users. I would create a
standard ASP page and then using include file I would reference
functions from the included file(s). Essentially I would parse a SQL
stored procedure and its parameters or a SQL command (in a string
format) from the users page, make a connection and return a recodset.
Then draw the page as per my recordset or required.

How do I do this in C# (within visual studio 2005)?

Please suggest common/best practice methodolgies and teminology.
Providing code examples would be great.

Thanks in advance.

Fabio

Oct 1 '07 #3

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

Similar topics

7
2578
by: David Berry | last post by:
I'm trying to use a recordset inside of a function but I'm getting an "object required 'adoRS" error. At the top of the page I create my recordset, ex: dim strConnection, adoCN, adoRS, strSQL strConnection = <Connection> Set adoCN = server.CreateObject("ADODB.connection") Set adoRS = server.CreateObject("ADODB.recordset") adoCN.Open strConnection
8
2309
by: dmiller23462 | last post by:
My brain is nuked....Can anybody tell me right off the bat what is wrong with this code? Along with any glaring errors, please let me know the syntax to display a message (Response.Write would be fine I think) that will say "I'm sorry but the data you requested cannot be found" or something along those lines.... This code is on an archive page I have on my company's intranet....The end result is to show 3 records at a time pulled from an...
5
29858
by: Simone | last post by:
Hello I hope you guys can help me. I am very new to ADO... I am creating a ADODB connection in a module and trying to access it from a command button in a form. Function fxEIDAssgn(plngEID As Long) As Boolean Dim rsAssignedUser As ADODB.Recordset Dim strSelectUser As String
6
3738
by: HKM | last post by:
Hello, I have a query engine that builds the SQL Query to obtain the recordSet. Following is an Exmaple Query that my QueryBuilder outputted SELECT * FROM BookInfo WHERE BookName LIKE '*cobol*' When I use this query to build recordset I get empty recordSet back when the BookInfo table has entries that qualify for this criteria. To
4
5727
by: Gerry Abbott | last post by:
Hi all. I wish to call a recordset from a function. Ive tried the following approach, -------------------------------------------------------- Function PassRS() As Recordset Dim db As Database Dim rs As Recordset Dim myQdf As QueryDef
6
6559
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query works fine, but passing the resulting recordset back to the sub's caller is not working out.
36
4486
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a dataview with a count = 0. Can someone explain why and how I might work around this problem? Here is the code for my function: Public Shared Function GetViewFromRS(ByVal pRS As ADODB.Recordset) _ As DataView
7
8373
by: marmottedodue | last post by:
Hello, I'm trying to debug an access project in which two kind of recordset are used: ADODB.recordset and DAO.recordset. I'm trying to set the whole project on DAO.recordset, but the following function does not work: Public Function GetRecordset(pstrCmdTxt As String, Optional pintCursorType As CursorTypeEnum = adOpenStatic) As Recordset ' was ADODB.recordset
5
5890
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public function returns a long string. This works. 2. A query has a calculated field based on the custom function above. This works when the query is run directly.
2
5522
by: wallconor | last post by:
Hi, I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my results page. - Recordset Paging works if no parameters are used in the recordset sql code (ie. simple sql code): SELECT * FROM db_name WHERE (db_field1 LIKE ‘%text1%’ OR db_field2 LIKE ‘%text2%’)
0
9825
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9673
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10560
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10602
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9388
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7795
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.