Passing an object as a parameter

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
 
M

Michael Per

Declare your oControl as a Control not as an Object. Control will have the
DataSource property and DataBind method.
 
A

Aymer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top