general db class, how to implement?

  • Thread starter Thread starter Kristoffer
  • Start date Start date
K

Kristoffer

Hi!
I have a general db class (a normal class, that contains the functions and
subs to enable me to connect to my database) ok...
but, HOW??

Do, I make use of this class in my asp.net application...
I need to contact it from my codebehind page...
but, I contact my codebehind page with the src= tag, so it compiles when I
contact the webpage, and not before...

the class is also a normal vb.net class, so its called dbclass.vb

How do I make use of this class from my codebehindpage?

eg...
member.ascx - Control, that shows the db info...
member.ascx.vb - Codebehindpage...
.../classes/dbclass.vb - the dbclass that handles the db connection...

dbclass example function, that I need to be able to contact from the
chkuserEmail sub...
Public Function readRS(ByVal strQuery As String) As Object

End Function


the member.ascx.vb page contains a sub that for instance is going to check
the db for something:
'--Custom Validators--

Sub ChkuserEmail(source As object, args As ServerValidateEventArgs)

How do I contact the readRS function from here???

End Sub


--


Kristoffer Arfvidson - (e-mail address removed)

Tel: +46 (0)733 - 442 660
Please visit us: www.arfvidson.se

Dansportalen - Nordens STÖRSTA webb om dans!
www.dansportalen.se (Finns nu på tre språk)
 
On your code behind page you could do something like this... (aircode, not
tested)

private sub populateGrid()
Dim oDataClass as new dbclass
Dim sSql as String("Select * from Something")
myDataGrid.Datasource = oDataClass.readRS(sSql)
myDataGrid.Databind()
end sub

Not sure if you are using ado or ado.net here though - I think you need an
ado.net dataset or data reader for binding to web controls... if you are
planning to do that anyway.

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
Access
 
Although you can't inherit the visual interface of a web page, your
codebehind class can be derived from another class. So:
1) Create a new web page to create the parent code-behind class, e.g.
WebPageAncestor. Ignore the .aspx user interface. Create all the "dbclass"
behaviour you need as methods of the WebPage Ancestor class in the
code-behind file.
2) For each new web page, make sure that the code behind class inherits from
WebPageAncestor instead of System.Web.UI.Page

HTH
 
Back
Top