Passing an object as a parameter

  • Thread starter Thread starter Aymer
  • Start date Start date
A

Aymer

Scenario: I have a datagrid object and a command object
in code-behind module.
dgFilings As DataGrid
Dim oCmd As SqlCommand

I have a function that I can re-use to bind different
objects.

Sub O_DataBind(oControl As Object, oCommand As SqlCommand)
Dim oAdapter As SqlDataAdapter
Dim oDataSet As DataSet

oAdapter = New SqlDataAdapter(oCommand)
oDataSet = New DataSet()
oAdapter.Fill(oDataSet)

oControl.DataSource = oDataSet
oControl.DataBind()
End Sub

So, I would pass in the datagrid object and a command
object into the function.
O_DataBind(dgFilings, oCmd)

I have "Option Strict True" turn on in my code-module.

Problem: Apparently, what i am doing is illegal under the
option strict rule. The error that it gives me
is: "BC30574: Option Strict On disallows late binding"

on line 123.
Line 121: oAdapter.Fill(oDataSet)
Line 122:
Line 123: oControl.DataSource = oDataSet
Line 124: oControl.DataBind()

How do i go around this dilemma? There has to be a
solution.

thanxs in advance,
aymer
aymerb[@].yahoo.com
 
Declare your oControl as a Control not as an Object. Control will have the
DataSource property and DataBind method.
 
the solution did not work. i declared oControl as a
Control instead of an object. the error given
states, "BC30456: 'DataSource' is not a member
of 'System.Web.UI.Control'."

so i still have a problem, but thanxs for the help.

peace,
aymer
aymerb[@].yahoo.com
 
Back
Top