Create additional classes. For data, downloading the Microsoft Data Access
Application block is a good start. You can then create business classes that
use the block to return data to pages.
If you want to merely pass through, make the methods in the class static
(Shared keyword in Visual Basic).
---
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"(E-Mail Removed)" wrote:
> I know in PHP it's possible to import another PHP file, so that you
> don't have to type the same code over and over again. I've been trying
> to find out how to do this with ASP.NET but haven't found a way. The
> code I have so far is:
> <%@ Page Language="VB" %>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.OleDb" %>
> <script runat="server">
>
> ' Insert page code here
> '
> Sub Page_Load(sender as Object, e as EventArgs)
> Dim connString as String
> connString = "Provider=Microsoft.Jet.OLEDB.4.0;DATA
> SOURCE=c:\phone.mdb;"
>
> Dim objConnection as OleDbConnection
> objConnection = New OleDbConnection(connString)
> objConnection.Open()
>
> Dim strSQL as String = "SELECT * FROM staff"
>
> Dim objCommand as OleDbCommand
> objCommand = New OleDbCommand(strSQL, objConnection)
>
> Dim objDataReader as OleDbDataReader
> objDataReader =
> objCommand.ExecuteReader(CommandBehavior.CloseConnection)
>
> lstNames.DataSource = objDataReader
> lstNames.DataBind()
>
> End Sub
>
> </script>
> <html>
> <head>
> </head>
> <body>
> <form runat="server">
> <!-- Insert content here -->
> <asp:listbox id="lstNames" runat="server"
> DataValueField="FIRSTNAME" DataTextField="FIRSTNAME"
> Rows="1"></asp:listbox>
> </form>
> </body>
> </html>
>
> I'd like to be able to chop out the code for the database connection,
> so that it starts right at lstNames.DataSource
> How do I go about doing this?
>
>
|