i'm new to ASP.NET and i've been trying to figure out ways to modularize some common code that i personally run into. i came up with the following code to allow one to bind data from ANY type of datastore (ie Oracle, SQL, Access, etc) to ANY bindable server control. the following code was converted from a very good article i read about a universal data access layer component (http://www.aspnextgen.com/tutorials.aspx?tutorialid=103).<BR><BR>------------------------------------------------<BR>DataAccessLayer.vb<BR>compile this VB file into a dll called<BR>DataAccessLayer.dll and put it in your<BR>application /bin directory<BR>------------------------------------------------<BR>Imports System<BR>Imports System.Web<BR>Imports System.Web.UI<BR>Imports System.Web.UI.WebControls<BR>Imports System.Web.UI.HtmlControls<BR>Imports System.Data<BR>Imports System.Data.OleDb<BR>Imports System.Configuration<BR><BR>Namespace DataAccessLayer<BR><BR>' this class uses the iDbConnection, IDataReader, and IDbCommand interfaces<BR>' to allow for connection to almost ANY datastore<BR> <BR>Public Class UniversalDAL<BR> Public Function GetData(conn As IDbConnection, commandText As String) As IDataReader<BR> Dim cmd As IDbCommand = conn.CreateCommand()<BR> cmd.CommandText = commandText<BR> Try <BR> conn.Open()<BR> Catch<BR> ' the connection is already open or was invalid<BR> End Try<BR> Return cmd.ExecuteReader()<BR> End Function<BR> End class<BR> <BR> Public Class DalCodeBehind : Inherits Page<BR> Public Function GetDataReader(sSQL As String) As OleDbDataReader<BR> Dim uDAL As New UniversalDAL()<BR> Dim oledbConn As New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString"))<BR> <BR> Dim myDataReader As OleDbDataReader<BR> myDataReader = uDAL.GetData(oledbConn,sSQL)<BR> <BR> Return myDataReader<BR> oledbConn.Close()<BR> End Function<BR> End Class<BR><BR>End Namespace<BR><BR><BR>--------------------------------------------------<BR>to use the above code in any web<BR>forms page, simply declare the following<BR>line at the top of the page<BR>--------------------------------------------------<BR><%@ Page Inherits="DataAccessLayer.DalCodeBehind" Language="VB" %><BR><BR>---------------------------------------------------<BR>now all you have to do is supply the SQL<BR>query string, and set the DataSource property<BR>of the server control to the DataReader<BR>that's returned, like so...<BR>---------------------------------------------------<BR><script runat="server"><BR>Dim sSQL As String = "SELECT TOP 4 Product_ID, Title FROM PRODUCTS ORDER BY Title"<BR><BR>dgProducts.DataSource = GetDataReader(sSQL)<BR>dgProducts.DataBind()<BR><BR>listProducts.DataSource = GetDataReader(sSQL)<BR>listProducts.DataBind()<BR><BR>radProducts.DataSource = GetDataReader(sSQL)<BR>radProducts.DataBind()<BR><BR>chkProducts.DataSource = GetDataReader(sSQL)<BR>chkProducts.DataBind()<BR></script><BR><BR>-------------------------------------------------------<BR><BR>the above code will generate a DataGrid, DropDownList, RadioButtonList, and CheckBoxList all generated from the database. <BR><BR>i'm sorry to throw a bunch of code up here, but i thought it would save some newbies like myself a little time and allow for future good coding practices. let me know if you have any questions. like i said, i'm very new to this so if any of you see ANY ways to improve this technique, please let me know. <BR><BR>thanks,<BR>../n1ck/