Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Question with despair - will buy movie tickets for the first one who helps

Reply
Thread Tools

Question with despair - will buy movie tickets for the first one who helps

 
 
Oliver
Guest
Posts: n/a
 
      11-22-2004
Hi,
I have spent my entire weekend trying to solve this, now I have to admit I
need your help.

Here is my code:

Dim cred() As DataSourceCredentials
Dim cc As New DataSourceCredentials
cred(0) = cc
cred(0).DataSourceName = "198.87.87.6"
cred(0).Password = "XXX"
cred(0).UserName = "YYY"

It crashes with the error message:Object Reference not set to
an instance of an Object

What am I missing?



 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBNVlA=?=
Guest
Posts: n/a
 
      11-22-2004
For your single operation, you can do something like this:

Dim cc As New DataSourceCredentials
Dim cred() As DataSourceCredentials = {cc}
cred(0).DataSourceName = "198.87.87.6"
cred(0).Password = "XXX"
cred(0).UserName = "YYY"

This is largely useless, but avoids the compile error. If you are going to
pop Credentials on and off the collection, you are better to set up cred as a
collection rather than a simple array.

You can also do something like:
Dim cred(1) As DataSourceCredentials
Dim cc As New DataSourceCredentials
cred(0) = cc
cred(0).DataSourceName = "198.87.87.6"
cred(0).Password = "XXX"
cred(0).UserName = "YYY"

And Redim for additional values, remember to use Preserve to avoid clearing
out the initial values. You biggest isssue is there is no size to your array.
In the first example, the size is implicitly set to 1; in the second it is
explcitly set.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Oliver" wrote:

> Hi,
> I have spent my entire weekend trying to solve this, now I have to admit I
> need your help.
>
> Here is my code:
>
> Dim cred() As DataSourceCredentials
> Dim cc As New DataSourceCredentials
> cred(0) = cc
> cred(0).DataSourceName = "198.87.87.6"
> cred(0).Password = "XXX"
> cred(0).UserName = "YYY"
>
> It crashes with the error message:Object Reference not set to
> an instance of an Object
>
> What am I missing?
>
>
>
>

 
Reply With Quote
 
 
 
 
Imran Koradia
Guest
Posts: n/a
 
      11-22-2004
"Cowboy (Gregory A. Beamer) - MVP" <> wrote
in message news:9745B80A-03ED-4FC7-8294-...
> For your single operation, you can do something like this:
>
> Dim cc As New DataSourceCredentials
> Dim cred() As DataSourceCredentials = {cc}
> cred(0).DataSourceName = "198.87.87.6"
> cred(0).Password = "XXX"
> cred(0).UserName = "YYY"
>
> This is largely useless, but avoids the compile error. If you are going to
> pop Credentials on and off the collection, you are better to set up cred

as a
> collection rather than a simple array.
>
> You can also do something like:
> Dim cred(1) As DataSourceCredentials
> Dim cc As New DataSourceCredentials
> cred(0) = cc
> cred(0).DataSourceName = "198.87.87.6"
> cred(0).Password = "XXX"
> cred(0).UserName = "YYY"
>
> And Redim for additional values, remember to use Preserve to avoid

clearing
> out the initial values. You biggest isssue is there is no size to your

array.
> In the first example, the size is implicitly set to 1; in the second it is
> explcitly set.


just a minor correction..in the second case, size is explicitly to 2 -
cred(0) will set the size to 1..apart from that all's good


Imran.


 
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
[Slightly OT] 'Quirks mode' wail of despair Simon Brooke XML 4 03-23-2007 10:25 AM
Here you can read books free and buy all tickets littlte woman Java 0 08-25-2006 12:09 AM
Here you can read books free and buy all tickets teun blsy Cisco 1 08-24-2006 07:59 PM
Was Photos from the iPod to the computer......DON'T DESPAIR! Tim Digital Photography 0 04-12-2006 08:44 PM
RE Despair - help required Yoav Python 10 08-25-2005 03:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57