Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Passing an object as a parameter

Reply
Thread Tools

Passing an object as a parameter

 
 
Aymer
Guest
Posts: n/a
 
      11-19-2003
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


 
Reply With Quote
 
 
 
 
Michael Per
Guest
Posts: n/a
 
      11-20-2003
Declare your oControl as a Control not as an Object. Control will have the
DataSource property and DataBind method.

"Aymer" <(E-Mail Removed)> wrote in message
news:022f01c3aedd$27d56dd0$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Aymer
Guest
Posts: n/a
 
      11-21-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing parameter to function not expecting parameter Mister B C Programming 8 08-26-2010 08:01 AM
Passing a temporary object to a reference parameter Martin Rennix C++ 3 05-07-2007 04:33 AM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
How do I fix "Argument not specified for parameter 'value' of 'Public Overridable Sub Add(key As Object, value As Object)" Chuck Insight ASP .Net Web Controls 2 03-19-2005 12:03 AM
Help Please: Passing Functor Object with Template type parameter CoolPint C++ 3 12-29-2003 03:25 PM



Advertisments