473,568 Members | 2,795 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 DataSourceCrede ntials
Dim cc As New DataSourceCrede ntials
cred(0) = cc
cred(0).DataSou rceName = "198.87.87. 6"
cred(0).Passwor d = "XXX"
cred(0).UserNam e = "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 1592
For your single operation, you can do something like this:

Dim cc As New DataSourceCrede ntials
Dim cred() As DataSourceCrede ntials = {cc}
cred(0).DataSou rceName = "198.87.87. 6"
cred(0).Passwor d = "XXX"
cred(0).UserNam e = "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 DataSourceCrede ntials
Dim cc As New DataSourceCrede ntials
cred(0) = cc
cred(0).DataSou rceName = "198.87.87. 6"
cred(0).Passwor d = "XXX"
cred(0).UserNam e = "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 DataSourceCrede ntials
Dim cc As New DataSourceCrede ntials
cred(0) = cc
cred(0).DataSou rceName = "198.87.87. 6"
cred(0).Passwor d = "XXX"
cred(0).UserNam e = "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.netNoS pamM> wrote
in message news:97******** *************** ***********@mic rosoft.com...
For your single operation, you can do something like this:

Dim cc As New DataSourceCrede ntials
Dim cred() As DataSourceCrede ntials = {cc}
cred(0).DataSou rceName = "198.87.87. 6"
cred(0).Passwor d = "XXX"
cred(0).UserNam e = "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 DataSourceCrede ntials
Dim cc As New DataSourceCrede ntials
cred(0) = cc
cred(0).DataSou rceName = "198.87.87. 6"
cred(0).Passwor d = "XXX"
cred(0).UserNam e = "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 DataSourceCrede ntials
Here you have created an array to hold DataSourceCrede ntials 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 DataSourceCrede ntials


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

For x as integer = 0 to 9
cred(x) = New DataSourceCrede ntials
cred(x).DataSou rceName = "198.87.87. 6"
cred(x).Passwor d = "XXX"
cred(x).UserNam e = "YYY"
Next

Hope this helps.

--
Chris

dunawayc[AT]sbcglobal_lunch meat_[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
22693
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 record. Tickets can also only have a closed record with no open record. Sample data table: ticket_id date_log status_name status_id
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 cred(0) = cc cred(0).DataSourceName = "198.87.87.6"
29
3545
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 one data field - but i'm not sure) :-) Background info:
0
948
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 New DataTable Public g_dbtGeneralInfo As New DataTable Public g_dbtSettings_Locations As New DataTable Public g_dbtSettings_Targets As New DataTable
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.