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

Discussion in 'ASP .Net' started by Oliver, Nov 22, 2004.

  1. Oliver

    Oliver Guest

    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?
     
    Oliver, Nov 22, 2004
    #1
    1. Advertising

  2. RE: Question with despair - will buy movie tickets for the first one w

    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?
    >
    >
    >
    >
     
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN, Nov 22, 2004
    #2
    1. Advertising

  3. Re: Question with despair - will buy movie tickets for the first one w

    "Cowboy (Gregory A. Beamer) - MVP" <> wrote
    in message news:...
    > 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.
     
    Imran Koradia, Nov 22, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. littlte woman
    Replies:
    0
    Views:
    302
    littlte woman
    Aug 25, 2006
  2. teun blsy
    Replies:
    0
    Views:
    507
    teun blsy
    Aug 25, 2006
  3. teun blsy
    Replies:
    0
    Views:
    326
    teun blsy
    Aug 27, 2006
  4. greatsee
    Replies:
    7
    Views:
    277
    Rich Townsend
    Aug 26, 2006
  5. greatsee
    Replies:
    7
    Views:
    257
    Rich Townsend
    Aug 26, 2006
Loading...

Share This Page