'Create ADO SQL Object in code Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load lblError.Visible = False Try '---instantiate my ADO class & create a new dataset 'OPTION 1: CREATE OBJECT & SET PROPERTIES 'Dim MyADO As New ADO_SQL 'MyADO.SQL = "Select * FROM Customers ORDER BY LName" 'MyADO.TableName = "customers" 'OPTION 2: CREATE OBJECT & PASS DATA AT THE SAME TIME Dim SQL As String = "Select * FROM Customers ORDER BY LName" Dim MyTableName As String = "customers" Dim MyADO As New ADO_SQL(SQL, MyTableName) '-------------------------------------------------------------------- '---create the DS Dim DS As New DataSet '---read the database & fill the DS MyADO.Execute(DS) '---tell Mr. Grid where to connect to With DataGrid1 .DataSource = DS .DataMember = MyTableName .DataKeyField = "CustID" End With '---make it so! DataGrid1.DataBind() Catch lblError.Visible = True lblError.Text = "I cannot connect to the database. " & Err.Description End Try End Sub