473,568 Members | 2,964 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
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...
0
6275
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
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...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
932
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.