Hello,
I'm not a developper, so sorry if it's a stupid question...
I'm trying to develop an application in vb.net and I have the following
problem:
I have some information in an array: sdist(i). The information is a string.
When I run the application, I don"t have problem for compilation but during
te execution, I have the error Cast from type 'Object()' to type 'String' is
not valid on the line: sdistinguishedname = Sdist(i). Or sdistinguishedname
is defined as string.
Do you have any idea ?
Thanks
Benoit 9 1911
How is declared/initialized the array ? It looks like you are trying to
assign an array of objects to a string...
--
"Ben" <Be*@discussions.microsoft.com> a écrit dans le message de
news:EE**********************************@microsof t.com... Hello,
I'm not a developper, so sorry if it's a stupid question... I'm trying to develop an application in vb.net and I have the following problem:
I have some information in an array: sdist(i). The information is a
string. When I run the application, I don"t have problem for compilation but
during te execution, I have the error Cast from type 'Object()' to type 'String'
is not valid on the line: sdistinguishedname = Sdist(i). Or
sdistinguishedname is defined as string.
Do you have any idea ?
Thanks
Benoit
Hi,
I am not sure how you declared the array. Following is the sample code
that might help you.
Dim test(4) as string
test(0) = "hello"
test(1) = "world"
test(2) = "hi"
Dim test1 as string
test1 = test(0)
Now test1 will have "hello" in it.
Thanks,
Sridhar.
"Ben" wrote: Hello,
I'm not a developper, so sorry if it's a stupid question... I'm trying to develop an application in vb.net and I have the following problem:
I have some information in an array: sdist(i). The information is a string. When I run the application, I don"t have problem for compilation but during te execution, I have the error Cast from type 'Object()' to type 'String' is not valid on the line: sdistinguishedname = Sdist(i). Or sdistinguishedname is defined as string.
Do you have any idea ?
Thanks
Benoit
Hello,
the array is declared like that:
Dim Sdist(100)
benoit
"Patrice" wrote: How is declared/initialized the array ? It looks like you are trying to assign an array of objects to a string...
--
"Ben" <Be*@discussions.microsoft.com> a écrit dans le message de news:EE**********************************@microsof t.com... Hello,
I'm not a developper, so sorry if it's a stupid question... I'm trying to develop an application in vb.net and I have the following problem:
I have some information in an array: sdist(i). The information is a string. When I run the application, I don"t have problem for compilation but during te execution, I have the error Cast from type 'Object()' to type 'String' is not valid on the line: sdistinguishedname = Sdist(i). Or sdistinguishedname is defined as string.
Do you have any idea ?
Thanks
Benoit
Hi,
I've just to try to change the declaration: dim dist(100) as string and I
have the same error but on an other line: "Cast from type 'Object()' to type
'String' is not "valid.
Sdist(i) = oRecordSet.Fields("distinguishedname").value
do you have an idea ?
"Ben" wrote: Hello,
the array is declared like that:
Dim Sdist(100)
benoit
"Patrice" wrote:
How is declared/initialized the array ? It looks like you are trying to assign an array of objects to a string...
--
"Ben" <Be*@discussions.microsoft.com> a écrit dans le message de news:EE**********************************@microsof t.com... Hello,
I'm not a developper, so sorry if it's a stupid question... I'm trying to develop an application in vb.net and I have the following problem:
I have some information in an array: sdist(i). The information is a string. When I run the application, I don"t have problem for compilation but during te execution, I have the error Cast from type 'Object()' to type 'String' is not valid on the line: sdistinguishedname = Sdist(i). Or sdistinguishedname is defined as string.
Do you have any idea ?
Thanks
Benoit
As you saw not specifying the type defaults to Object (i.e. it was an array
of objects).
Now it looks like oRecordsset.Fields("distinguishedname").value returns an
array of objects. It would be consistent with the previous behavior (ie. it
returned an array of object that you put in a cell as an object and later
you tried to assign this in a string).
So finally the culprit should be
oRecordSet.Fields("distinguishedname").value. Not frequent but it looks like
you are retrieving a multivalued field (from LDAP ?)
--
"Ben" <Be*@discussions.microsoft.com> a écrit dans le message de
news:69**********************************@microsof t.com... Hi,
I've just to try to change the declaration: dim dist(100) as string and I have the same error but on an other line: "Cast from type 'Object()' to
type 'String' is not "valid.
Sdist(i) = oRecordSet.Fields("distinguishedname").value
do you have an idea ?
"Ben" wrote:
Hello,
the array is declared like that:
Dim Sdist(100)
benoit
"Patrice" wrote:
How is declared/initialized the array ? It looks like you are trying
to assign an array of objects to a string...
--
"Ben" <Be*@discussions.microsoft.com> a écrit dans le message de news:EE**********************************@microsof t.com... > Hello, > > I'm not a developper, so sorry if it's a stupid question... > I'm trying to develop an application in vb.net and I have the
following > problem: > > I have some information in an array: sdist(i). The information is a string. > When I run the application, I don"t have problem for compilation but during > te execution, I have the error Cast from type 'Object()' to type
'String' is > not valid on the line: sdistinguishedname = Sdist(i). Or sdistinguishedname > is defined as string. > > Do you have any idea ? > > Thanks > > Benoit >
You're right, it 's for LDAP query.
If I use a "watch", I can see:
Name
oRecordSet.Fields("distinguishedname").Value = > type object
(0) = > type string
Value
{System.Array} = > type object
"test string" = > type string
Do you know how I can do ?
"Patrice" wrote: As you saw not specifying the type defaults to Object (i.e. it was an array of objects).
Now it looks like oRecordsset.Fields("distinguishedname").value returns an array of objects. It would be consistent with the previous behavior (ie. it returned an array of object that you put in a cell as an object and later you tried to assign this in a string).
So finally the culprit should be oRecordSet.Fields("distinguishedname").value. Not frequent but it looks like you are retrieving a multivalued field (from LDAP ?)
--
"Ben" <Be*@discussions.microsoft.com> a écrit dans le message de news:69**********************************@microsof t.com... Hi,
I've just to try to change the declaration: dim dist(100) as string and I have the same error but on an other line: "Cast from type 'Object()' to type 'String' is not "valid.
Sdist(i) = oRecordSet.Fields("distinguishedname").value
do you have an idea ?
"Ben" wrote:
Hello,
the array is declared like that:
Dim Sdist(100)
benoit
"Patrice" wrote:
> How is declared/initialized the array ? It looks like you are trying to > assign an array of objects to a string... > > -- > > "Ben" <Be*@discussions.microsoft.com> a écrit dans le message de > news:EE**********************************@microsof t.com... > > Hello, > > > > I'm not a developper, so sorry if it's a stupid question... > > I'm trying to develop an application in vb.net and I have the following > > problem: > > > > I have some information in an array: sdist(i). The information is a > string. > > When I run the application, I don"t have problem for compilation but > during > > te execution, I have the error Cast from type 'Object()' to type 'String' > is > > not valid on the line: sdistinguishedname = Sdist(i). Or > sdistinguishedname > > is defined as string. > > > > Do you have any idea ? > > > > Thanks > > > > Benoit > > > > >
AFAIK some LDAP fields are actually arrays... So you would have to test if
this is an array and to react accordingly.
What annoys me for now is that AFAIK the distinguishedname is NOT
multivalued. Is this field the "real" distinguishedname LDAP value ?
You could try something like (not tested) :
o=oRecordSet.Fields("distinguishedname").Value
If IsArray(o) Then
For i=0 to Ubound(o)
MsgBox o(i)
Next
Else
Mgbox("Not an array")
End If
To see what values are returned in this array. It would perhaps allows to
find out if this the info you expected or some other kind of information
than the distinguishedname...
Good luck.
--
Patrice
"Ben" <Be*@discussions.microsoft.com> a écrit dans le message de
news:20**********************************@microsof t.com... You're right, it 's for LDAP query. If I use a "watch", I can see:
Name oRecordSet.Fields("distinguishedname").Value = > type object
(0) = > type string
Value {System.Array} = > type object "test string" = > type string
Do you know how I can do ? "Patrice" wrote:
As you saw not specifying the type defaults to Object (i.e. it was an
array of objects).
Now it looks like oRecordsset.Fields("distinguishedname").value returns
an array of objects. It would be consistent with the previous behavior (ie.
it returned an array of object that you put in a cell as an object and
later you tried to assign this in a string).
So finally the culprit should be oRecordSet.Fields("distinguishedname").value. Not frequent but it looks
like you are retrieving a multivalued field (from LDAP ?)
--
"Ben" <Be*@discussions.microsoft.com> a écrit dans le message de news:69**********************************@microsof t.com... Hi,
I've just to try to change the declaration: dim dist(100) as string
and I have the same error but on an other line: "Cast from type 'Object()'
to type 'String' is not "valid.
Sdist(i) = oRecordSet.Fields("distinguishedname").value
do you have an idea ?
"Ben" wrote:
> Hello, > > the array is declared like that: > > Dim Sdist(100) > > benoit > > "Patrice" wrote: > > > How is declared/initialized the array ? It looks like you are
trying to > > assign an array of objects to a string... > > > > -- > > > > "Ben" <Be*@discussions.microsoft.com> a écrit dans le message de > > news:EE**********************************@microsof t.com... > > > Hello, > > > > > > I'm not a developper, so sorry if it's a stupid question... > > > I'm trying to develop an application in vb.net and I have the following > > > problem: > > > > > > I have some information in an array: sdist(i). The information
is a > > string. > > > When I run the application, I don"t have problem for compilation
but > > during > > > te execution, I have the error Cast from type 'Object()' to type 'String' > > is > > > not valid on the line: sdistinguishedname = Sdist(i). Or > > sdistinguishedname > > > is defined as string. > > > > > > Do you have any idea ? > > > > > > Thanks > > > > > > Benoit > > > > > > > > >
oh yes it's a good idea.
I'm going to test and I'll let you know
Benoit
"Patrice" wrote: AFAIK some LDAP fields are actually arrays... So you would have to test if this is an array and to react accordingly.
What annoys me for now is that AFAIK the distinguishedname is NOT multivalued. Is this field the "real" distinguishedname LDAP value ?
You could try something like (not tested) :
o=oRecordSet.Fields("distinguishedname").Value If IsArray(o) Then For i=0 to Ubound(o) MsgBox o(i) Next Else Mgbox("Not an array") End If
To see what values are returned in this array. It would perhaps allows to find out if this the info you expected or some other kind of information than the distinguishedname...
Good luck. -- Patrice
"Ben" <Be*@discussions.microsoft.com> a écrit dans le message de news:20**********************************@microsof t.com... You're right, it 's for LDAP query. If I use a "watch", I can see:
Name oRecordSet.Fields("distinguishedname").Value = > type object
(0) = > type string
Value {System.Array} = > type object "test string" = > type string
Do you know how I can do ? "Patrice" wrote:
As you saw not specifying the type defaults to Object (i.e. it was an array of objects).
Now it looks like oRecordsset.Fields("distinguishedname").value returns an array of objects. It would be consistent with the previous behavior (ie. it returned an array of object that you put in a cell as an object and later you tried to assign this in a string).
So finally the culprit should be oRecordSet.Fields("distinguishedname").value. Not frequent but it looks like you are retrieving a multivalued field (from LDAP ?)
--
"Ben" <Be*@discussions.microsoft.com> a écrit dans le message de news:69**********************************@microsof t.com... > Hi, > > I've just to try to change the declaration: dim dist(100) as string and I > have the same error but on an other line: "Cast from type 'Object()' to type > 'String' is not "valid. > > Sdist(i) = oRecordSet.Fields("distinguishedname").value > > do you have an idea ? > > "Ben" wrote: > > > Hello, > > > > the array is declared like that: > > > > Dim Sdist(100) > > > > benoit > > > > "Patrice" wrote: > > > > > How is declared/initialized the array ? It looks like you are trying to > > > assign an array of objects to a string... > > > > > > -- > > > > > > "Ben" <Be*@discussions.microsoft.com> a écrit dans le message de > > > news:EE**********************************@microsof t.com... > > > > Hello, > > > > > > > > I'm not a developper, so sorry if it's a stupid question... > > > > I'm trying to develop an application in vb.net and I have the following > > > > problem: > > > > > > > > I have some information in an array: sdist(i). The information is a > > > string. > > > > When I run the application, I don"t have problem for compilation but > > > during > > > > te execution, I have the error Cast from type 'Object()' to type 'String' > > > is > > > > not valid on the line: sdistinguishedname = Sdist(i). Or > > > sdistinguishedname > > > > is defined as string. > > > > > > > > Do you have any idea ? > > > > > > > > Thanks > > > > > > > > Benoit > > > > > > > > > > > > >
Patrice, thanks, It seems better now.
Benoit
"Patrice" wrote: AFAIK some LDAP fields are actually arrays... So you would have to test if this is an array and to react accordingly.
What annoys me for now is that AFAIK the distinguishedname is NOT multivalued. Is this field the "real" distinguishedname LDAP value ?
You could try something like (not tested) :
o=oRecordSet.Fields("distinguishedname").Value If IsArray(o) Then For i=0 to Ubound(o) MsgBox o(i) Next Else Mgbox("Not an array") End If
To see what values are returned in this array. It would perhaps allows to find out if this the info you expected or some other kind of information than the distinguishedname...
Good luck. -- Patrice
"Ben" <Be*@discussions.microsoft.com> a écrit dans le message de news:20**********************************@microsof t.com... You're right, it 's for LDAP query. If I use a "watch", I can see:
Name oRecordSet.Fields("distinguishedname").Value = > type object
(0) = > type string
Value {System.Array} = > type object "test string" = > type string
Do you know how I can do ? "Patrice" wrote:
As you saw not specifying the type defaults to Object (i.e. it was an array of objects).
Now it looks like oRecordsset.Fields("distinguishedname").value returns an array of objects. It would be consistent with the previous behavior (ie. it returned an array of object that you put in a cell as an object and later you tried to assign this in a string).
So finally the culprit should be oRecordSet.Fields("distinguishedname").value. Not frequent but it looks like you are retrieving a multivalued field (from LDAP ?)
--
"Ben" <Be*@discussions.microsoft.com> a écrit dans le message de news:69**********************************@microsof t.com... > Hi, > > I've just to try to change the declaration: dim dist(100) as string and I > have the same error but on an other line: "Cast from type 'Object()' to type > 'String' is not "valid. > > Sdist(i) = oRecordSet.Fields("distinguishedname").value > > do you have an idea ? > > "Ben" wrote: > > > Hello, > > > > the array is declared like that: > > > > Dim Sdist(100) > > > > benoit > > > > "Patrice" wrote: > > > > > How is declared/initialized the array ? It looks like you are trying to > > > assign an array of objects to a string... > > > > > > -- > > > > > > "Ben" <Be*@discussions.microsoft.com> a écrit dans le message de > > > news:EE**********************************@microsof t.com... > > > > Hello, > > > > > > > > I'm not a developper, so sorry if it's a stupid question... > > > > I'm trying to develop an application in vb.net and I have the following > > > > problem: > > > > > > > > I have some information in an array: sdist(i). The information is a > > > string. > > > > When I run the application, I don"t have problem for compilation but > > > during > > > > te execution, I have the error Cast from type 'Object()' to type 'String' > > > is > > > > not valid on the line: sdistinguishedname = Sdist(i). Or > > > sdistinguishedname > > > > is defined as string. > > > > > > > > Do you have any idea ? > > > > > > > > Thanks > > > > > > > > Benoit > > > > > > > > > > > > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Daylor |
last post by:
first of all , PLEASE,say somthing..about my post.
any reply will be nice to read.
i have vb.app , with 2 appdomains.
(now, in the next section , ill write "appdomain create" ,means a code in...
|
by: Dave Byron |
last post by:
I am having trouble with DBNull's from my SQL server. I am
building/converting a asset web app from Access and my db has nulls on
various fields . I have tried searching newsgroups and tried to get...
|
by: CA |
last post by:
Hi,
I have a function where I would like to test whether an object is of a
certain type. Here is my code so far.
public bool HasValidType(Type t, object val)
{
try
{
if (t==typeof(double))
|
by: Jim H |
last post by:
I am trying to go through my Outlook (2003) address book. The code goes
through the Items list and prints all the last names but after it hits 114
(out or 126 contacts) I get a "sepcified cast is...
|
by: Jack MacRank |
last post by:
Hello,
I'm coding a webform application in C# (ASP.NET 1.1 SP1 with VS.NET 2003 Pro
on WinXP SP2 using IIS 5.1).
I created a seperate "data" class to house all the MySQL connection and sql...
|
by: John Howard |
last post by:
Making the following call to a local MSAccess database works fine:
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim intRows As Integer
Dim strSQL As String
Dim ds As New...
|
by: Fabian |
last post by:
Hi,
I work with asp.net 2.0 and I have a intermittent error, only happens a few
times a day.
In the page I evaluate a Query String and then I get data form a database.
The code snipped:
...
|
by: John-Arne Lillebø |
last post by:
Hi.
I run into this problem and i could need some help to solve it.
The project is an ASP.NET Web project.
Including code sample of the problem.
Any idea what is causing the error message ?...
|
by: Gamma |
last post by:
I'm trying to inherit subclass from System.Diagnostics.Process, but
whenever I cast a "Process" object to it's subclass, I encounter an
exception "System.InvalidCastException" ("Specified cast is...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| |