473,327 Members | 2,069 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,327 software developers and data experts.

Late binding problem

I have the following in my VS 2008 code:

parameters(0).Value = Session("User").CompanyID

I assume this means that since there is no "User" at this point I can't do
this.

But it will be there and the User Object has a CompanyID property.

How can I access this in my code?

Thanks,

Tom
Sep 13 '08 #1
15 1251
I also have the same problem with:

Sub SetMoveList_Click(ByVal s As Object, ByVal e As EventArgs)
Trace.Warn("in SetMove_Click s.id = " & s.id)
Dim oPanel As Panel = s.parent
Dim oDLI As DataListItem = s.parent.parent

I am getting the error on s.id, s.parent and s.parent.parent.

I used to do this in 2003 - how would I do the same thing here?

Thanks,

Tom

"tshad" <tf*@dslextreme.comwrote in message
news:eG**************@TK2MSFTNGP04.phx.gbl...
>I have the following in my VS 2008 code:

parameters(0).Value = Session("User").CompanyID

I assume this means that since there is no "User" at this point I can't do
this.

But it will be there and the User Object has a CompanyID property.

How can I access this in my code?

Thanks,

Tom

Sep 13 '08 #2
"tshad" <tf*@dslextreme.comwrote in message
news:eG**************@TK2MSFTNGP04.phx.gbl...
I have the following in my VS 2008 code:

parameters(0).Value = Session("User").CompanyID

I assume this means that since there is no "User" at this point I can't do
this.

But it will be there and the User Object has a CompanyID property.

How can I access this in my code?
You appear to be using VB.NET instead of C#, so it's probably something
like:

If Session("User") Is Not Nothing Then
parameters(0).Value = Session("User").CompanyID
End If
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 13 '08 #3
tshad wrote:
I have the following in my VS 2008 code:

parameters(0).Value = Session("User").CompanyID

I assume this means that since there is no "User" at this point I can't do
this.

But it will be there and the User Object has a CompanyID property.

How can I access this in my code?
Hi Tom,
as far as I see you have the problem that "CompanyID" is not known at
that moment (or is this different in VB.NET?). In that case you have to
cast the result of Session("User") to the object you expect. Maybe this
helps you: http://www.codeproject.com/KB/dotnet...astingNET.aspx

Best,
Hilmar
Sep 13 '08 #4

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"tshad" <tf*@dslextreme.comwrote in message
news:eG**************@TK2MSFTNGP04.phx.gbl...
>I have the following in my VS 2008 code:

parameters(0).Value = Session("User").CompanyID

I assume this means that since there is no "User" at this point I can't
do this.

But it will be there and the User Object has a CompanyID property.

How can I access this in my code?

You appear to be using VB.NET instead of C#, so it's probably something
like:

If Session("User") Is Not Nothing Then
parameters(0).Value = Session("User").CompanyID
End If
You're right I am using VB.Net and Option Strict On.

Tried that but got the same error.

The actual statement is:

If Not Session("User") Is Nothing Then

But that didn't help in any case.

Thanks,

Tom
>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 13 '08 #5

"Hilmar Bunjes" <ne*******@silveraxe.dewrote in message
news:48**********************@newsspool4.arcor-online.net...
tshad wrote:
>I have the following in my VS 2008 code:

parameters(0).Value = Session("User").CompanyID

I assume this means that since there is no "User" at this point I can't
do this.

But it will be there and the User Object has a CompanyID property.

How can I access this in my code?

Hi Tom,
as far as I see you have the problem that "CompanyID" is not known at that
moment (or is this different in VB.NET?). In that case you have to cast
the result of Session("User") to the object you expect. Maybe this helps
you: http://www.codeproject.com/KB/dotnet...astingNET.aspx
I think you are right.

User is a class so would need to be cast as one. If I have Option Strict
Off, I don't have to.

Thanks,

Tom
Best,
Hilmar

Sep 13 '08 #6
"tshad" <tf*@dslextreme.comwrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...
Tried that but got the same error.
Are you going to tell the group what the error actually was...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 13 '08 #7

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
"tshad" <tf*@dslextreme.comwrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...
>Tried that but got the same error.

Are you going to tell the group what the error actually was...?
My mistake. I thought I did.

I am getting:

Error 54 Option Strict On disallows late binding.

I get this for:

parameters(0).Value = Session("User").CompanyID

Where User is a class.

And I also get it for:

Sub SetMoveList_Click(ByVal s As Object, ByVal e As EventArgs)
Trace.Warn("in SetMove_Click s.id = " & s.id)
Dim oPanel As Panel = s.parent
Dim oDLI As DataListItem = s.parent.parent

Here I am trying to get the Panel and DataListItem which works fine if
Option Strict is Off.

Why would this be a problem with it on. "s" is an object and objects have
parents.

Thanks,

Tom
>

--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 13 '08 #8
"tshad" <tf*@dslextreme.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
>>Tried that but got the same error.

Are you going to tell the group what the error actually was...?

My mistake. I thought I did.

I am getting:

Error 54 Option Strict On disallows late binding.
I never use VB.NET, but do none of the very many results of a Google search
on this help at all...?
http://www.google.co.uk/search?sourc...ate+binding%22
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 13 '08 #9
tshad wrote:
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>"tshad" <tf*@dslextreme.comwrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...
>>Tried that but got the same error.
Are you going to tell the group what the error actually was...?

My mistake. I thought I did.

I am getting:

Error 54 Option Strict On disallows late binding.

I get this for:

parameters(0).Value = Session("User").CompanyID

Where User is a class.

And I also get it for:

Sub SetMoveList_Click(ByVal s As Object, ByVal e As EventArgs)
Trace.Warn("in SetMove_Click s.id = " & s.id)
Dim oPanel As Panel = s.parent
Dim oDLI As DataListItem = s.parent.parent

Here I am trying to get the Panel and DataListItem which works fine if
Option Strict is Off.

Why would this be a problem with it on. "s" is an object and objects have
parents.

Thanks,

Tom
>>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

First off objects do not have parents. What you need to do is use CType
to tell the compiler what the objects are. For example s is not an
object, it is a class that is derived from object. So whatever
SetMoveList is , is the object type in the CType statement.

Something like:

dim oPanel as Panel = ctype(s,HtmlButton).parent

This will allow the compiler to know that s is infact an HtmlButton (you
need to know what type it is).

You will have to do the same with s.parent.parent

LS
Sep 13 '08 #10

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:eb**************@TK2MSFTNGP06.phx.gbl...
"tshad" <tf*@dslextreme.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
>>>Tried that but got the same error.

Are you going to tell the group what the error actually was...?

My mistake. I thought I did.

I am getting:

Error 54 Option Strict On disallows late binding.

I never use VB.NET, but do none of the very many results of a Google
search on this help at all...?
http://www.google.co.uk/search?sourc...ate+binding%22
I figured it out.

s.parent

needs to be changed to:

CType(s, DataGridItem).Parent.Parent

Thanks,

Tom
>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 13 '08 #11

"tshad" <tf*@dslextreme.comwrote in message
news:us***************@TK2MSFTNGP06.phx.gbl...
>
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:eb**************@TK2MSFTNGP06.phx.gbl...
>"tshad" <tf*@dslextreme.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
>>>>Tried that but got the same error.

Are you going to tell the group what the error actually was...?

My mistake. I thought I did.

I am getting:

Error 54 Option Strict On disallows late binding.

I never use VB.NET, but do none of the very many results of a Google
search on this help at all...?
http://www.google.co.uk/search?sourc...ate+binding%22
I figured it out.

s.parent

needs to be changed to:

CType(s, DataGridItem).Parent.Parent
This doesn't make a lot of sense, however.

We know that "s" is an object and objects have parents as properties (don't
they?).

So why do I need to change this:

s.Parent.GetType().ToString()

to
CType(s, ImageButton).Parent.GetType().ToString()

Is that really late binding?

Thanks,

Tom
>
Thanks,

Tom
>>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


Sep 13 '08 #12

"Lloyd Sheen" <a@b.cwrote in message
news:uj*************@TK2MSFTNGP06.phx.gbl...
tshad wrote:
>"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>"tshad" <tf*@dslextreme.comwrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...

Tried that but got the same error.
Are you going to tell the group what the error actually was...?

My mistake. I thought I did.

I am getting:

Error 54 Option Strict On disallows late binding.

I get this for:

parameters(0).Value = Session("User").CompanyID

Where User is a class.

And I also get it for:

Sub SetMoveList_Click(ByVal s As Object, ByVal e As EventArgs)
Trace.Warn("in SetMove_Click s.id = " & s.id)
Dim oPanel As Panel = s.parent
Dim oDLI As DataListItem = s.parent.parent

Here I am trying to get the Panel and DataListItem which works fine if
Option Strict is Off.

Why would this be a problem with it on. "s" is an object and objects
have parents.

Thanks,

Tom
>>>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


First off objects do not have parents. What you need to do is use CType to
tell the compiler what the objects are. For example s is not an object,
it is a class that is derived from object.
What?

It is defined as an object:

ByVal s As Object
>So whatever SetMoveList is , is the object type in the CType statement.
I thought objects had parents. Maybe that was because I used to write my
code with Option Strict Off (actually defaulted to that) and I would use
s.Parent all the time.

If objects don't have parents, do I need to change:

s.Parent,Parent,Parent to something like:

CType(CType(Ctype(CType(s,something).Parent,someth ing).Parent,something).Parent,something)

Because in each case we would need to know what the parent is.

Also, why does this work:

I don't this is the case as this works:

Dim theParent As Control = CType(sender,DataGridItem).Parent.Parent

I don't need to cast each parent.

But I do need to cast this:

Dim oDataList As DataListItem = CType(CType(s, ImageButton).Parent.Parent,
DataListItem)

Doesn't seem too consistant
Something like:

dim oPanel as Panel = ctype(s,HtmlButton).parent
But would you not nee to Ctype the whole thing as Panel?
>
This will allow the compiler to know that s is infact an HtmlButton (you
need to know what type it is).

You will have to do the same with s.parent.parent

LS

Sep 13 '08 #13
tshad wrote:
"tshad" <tf*@dslextreme.comwrote in message
news:us***************@TK2MSFTNGP06.phx.gbl...
>"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:eb**************@TK2MSFTNGP06.phx.gbl...
>>"tshad" <tf*@dslextreme.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...

>Tried that but got the same error.
Are you going to tell the group what the error actually was...?
My mistake. I thought I did.

I am getting:

Error 54 Option Strict On disallows late binding.
I never use VB.NET, but do none of the very many results of a Google
search on this help at all...?
http://www.google.co.uk/search?sourc...ate+binding%22
I figured it out.

s.parent

needs to be changed to:

CType(s, DataGridItem).Parent.Parent

This doesn't make a lot of sense, however.

We know that "s" is an object and objects have parents as properties (don't
they?).

So why do I need to change this:

s.Parent.GetType().ToString()

to
CType(s, ImageButton).Parent.GetType().ToString()

Is that really late binding?

Thanks,

Tom
>Thanks,

Tom
>>--
Mark Rae
ASP.NET MVP
http://www.markrae.net


The Object class is the base class for all others. It does not have a
parent property.

LS
Sep 13 '08 #14

"Lloyd Sheen" <a@b.cwrote in message
news:uL**************@TK2MSFTNGP02.phx.gbl...
tshad wrote:
>"tshad" <tf*@dslextreme.comwrote in message
news:us***************@TK2MSFTNGP06.phx.gbl...
>>"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:eb**************@TK2MSFTNGP06.phx.gbl...
"tshad" <tf*@dslextreme.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl.. .

>>Tried that but got the same error.
>Are you going to tell the group what the error actually was...?
My mistake. I thought I did.
>
I am getting:
>
Error 54 Option Strict On disallows late binding.
I never use VB.NET, but do none of the very many results of a Google
search on this help at all...?
http://www.google.co.uk/search?sourc...ate+binding%22

I figured it out.

s.parent

needs to be changed to:

CType(s, DataGridItem).Parent.Parent

This doesn't make a lot of sense, however.

We know that "s" is an object and objects have parents as properties
(don't they?).

So why do I need to change this:

s.Parent.GetType().ToString()

to
CType(s, ImageButton).Parent.GetType().ToString()

Is that really late binding?

Thanks,

Tom
>>Thanks,

Tom
--
Mark Rae
ASP.NET MVP
http://www.markrae.net



The Object class is the base class for all others. It does not have a
parent property.
Ok, that makes sense. But then why does this work?

Dim oDGI As DataGridItem = CType(CType(s, RadioButton).Parent.Parent,
DataGridItem)

How come I can do a Parent.Parent?

Isn't the first Parent an object - CType(s, RadioButton).Parent - since I
didn't type that one? The CType for the 2nd Parent I understand?

Thanks,

Tom

>
LS

Sep 14 '08 #15
tshad wrote:
"Lloyd Sheen" <a@b.cwrote in message
news:uL**************@TK2MSFTNGP02.phx.gbl...
>tshad wrote:
>>"tshad" <tf*@dslextreme.comwrote in message
news:us***************@TK2MSFTNGP06.phx.gbl...
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:eb**************@TK2MSFTNGP06.phx.gbl...
"tshad" <tf*@dslextreme.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl. ..
>
>>>Tried that but got the same error.
>>Are you going to tell the group what the error actually was...?
>My mistake. I thought I did.
>>
>I am getting:
>>
>Error 54 Option Strict On disallows late binding.
I never use VB.NET, but do none of the very many results of a Google
search on this help at all...?
http://www.google.co.uk/search?sourc...ate+binding%22
>
I figured it out.

s.parent

needs to be changed to:

CType(s, DataGridItem).Parent.Parent
This doesn't make a lot of sense, however.

We know that "s" is an object and objects have parents as properties
(don't they?).

So why do I need to change this:

s.Parent.GetType().ToString()

to
CType(s, ImageButton).Parent.GetType().ToString()

Is that really late binding?

Thanks,

Tom

Thanks,

Tom
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

The Object class is the base class for all others. It does not have a
parent property.

Ok, that makes sense. But then why does this work?

Dim oDGI As DataGridItem = CType(CType(s, RadioButton).Parent.Parent,
DataGridItem)

How come I can do a Parent.Parent?

Isn't the first Parent an object - CType(s, RadioButton).Parent - since I
didn't type that one? The CType for the 2nd Parent I understand?

Thanks,

Tom

>LS

You have given the compiler a start on what the "object" really is.
When you "cast" the object as a RadioButton the compiler will know what
that the parent of a RadioButton is a certain set of objects, all of
which have a parent property.

LS
Sep 14 '08 #16

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

Similar topics

21
by: Mike MacSween | last post by:
Had some trouble with Word automation. Sorted it, in the process thought I would try late binding. Some people reccomend it. So this: *********************************************************...
1
by: JD Kronicz | last post by:
Hi .. I have an issue I have been beating my head against the wall on for some time. I am trying to use late binding for MS graph so that my end users don't have to worry about having the right...
7
by: PC Datasheet | last post by:
I have this: Dim Cbr As Object Dim Ctl As Object Set Cbr = Application.Commandbars("CourseCalendarMonth") Set Ctl = Application.Commandbars("CourseCalendarMonth").Controls("CalendarMonth") Is...
14
by: Composer | last post by:
I've read many postings about the problem of Access.References.IsBroken and the consensus seems to be that late binding is the cure-all. I have a very complex Access application that needs...
9
by: Zlatko Matić | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
8
by: scorpion53061 | last post by:
I am sorry for this but I am not getting an answer elsewhere so I thought I would try here. It seems the safer way to go prior to deployment is to change my early binding to late binding to...
30
by: lgbjr | last post by:
hi All, I've decided to use Options Strict ON in one of my apps and now I'm trying to fix a late binding issue. I have 5 integer arrays: dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as...
6
by: Tim Roberts | last post by:
I've been doing COM a long time, but I've just come across a behavior with late binding that surprises me. VB and VBS are not my normal milieux, so I'm hoping someone can point me to a document...
1
by: Adotek | last post by:
Hi All, I've just converted a solution from .Net v1.1 to v2.0, by allowing Visual Studio 2005 to do the conversion. Since doing so, I am getting a compilation error as follows: "Option...
14
by: Siv | last post by:
hi, I am converting an application that writes to an Excel spreadsheet and the code trips the "option Strict" that I would like on because the parser says "option Strict On disallows late...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.