473,385 Members | 1,218 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Passing an object as a parameter

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
Nov 18 '05 #1
2 1469
Declare your oControl as a Control not as an Object. Control will have the
DataSource property and DataBind method.

"Aymer" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
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

Nov 18 '05 #2
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
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Andy | last post by:
Hi Could someone clarify for me the method parameter passing concept? As I understand it, if you pass a variable without the "ref" syntax then it gets passed as a copy. If you pass a...
8
by: Dennis Myrén | last post by:
I have these tiny classes, implementing an interface through which their method Render ( CosWriter writer ) ; is called. Given a specific context, there are potentially a lot of such objects,...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
6
by: MSDNAndi | last post by:
Hi, I get the following warning: "Possibly incorrect assignment to local 'oLockObject' which is the argument to a using or lock statement. The Dispose call or unlocking will happen on the...
10
by: amazon | last post by:
Our vender provided us a web service: 1xyztest.xsd file... ------------------------------------ postEvent PostEventRequest ------------------------------------- authetication authentication...
0
by: amazon | last post by:
I have web service that acceping following parameters.. postev.PostEvent(authentication as ws.authentication, name as string,id as string, exdate as date, parameter() as ws.nameparametervaluepair...
7
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
12
by: dave_dp | last post by:
Hi, I have just started learning C++ language.. I've read much even tried to understand the way standard says but still can't get the grasp of that concept. When parameters are passed/returned...
10
by: Janus | last post by:
Hi, Is there a way to pass arguments to the callback function used inside an addEventListener? I see that I can only list the name of the callback function. For eg, I use this: var...
4
by: Deckarep | last post by:
Hello fellow C# programmers, This question is more about general practice and convention so here goes: I got into a discussion with a co-worker who insisted that as a general practice all...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.