473,503 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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?

Jul 21 '05 #1
3 1587
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?

Jul 21 '05 #2
"Cowboy (Gregory A. Beamer) - MVP" <No************@comcast.netNoSpamM> wrote
in message news:97**********************************@microsof t.com...
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.
Jul 21 '05 #3
On Mon, 22 Nov 2004 10:46:41 -0500, Oliver wrote:
Dim cred() As DataSourceCredentials
Here you have created an array to hold DataSourceCredentials objects, but
it is empty, that is, it has no elements in it. You need to first ReDim
the array to hold the number of objects you need:

ReDim cred(9) 'Use whatever number is appropriate for your situation
Dim cc As New DataSourceCredentials


This line is unnecessary, instead, use something like this:

For x as integer = 0 to 9
cred(x) = New DataSourceCredentials
cred(x).DataSourceName = "198.87.87.6"
cred(x).Password = "XXX"
cred(x).UserName = "YYY"
Next

Hope this helps.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Jul 21 '05 #4

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

Similar topics

4
22689
by: Spark | last post by:
Hi, Situation: Need a query to return number of ticket records by month of open in a log table where the ticket open record is older than 24 hours then the ticket pending or ticket closed...
3
259
by: Oliver | last post by:
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...
29
3537
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this...
0
944
by: Radu | last post by:
Hi. In a public module which I have named "MAIN.VB", I use something like this: Public g_strRequestorsPIN As String Public g_strWebSiteLanguage As String Public g_dbtSettings_HeaderInfo As...
0
7201
marktang
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,...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7456
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
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,...
1
5011
isladogs
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...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.