473,385 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

C#, DB2 & String Arrays

Hi,

I need to connect to a DB2 database, make a select * from table where like =
'somevalue'.

Then I need to copy thos values into a string array.

Any ideas?

Thanks
Nov 18 '05 #1
4 1628
Go to www.connectionstrings.com and take one of the suggested ones for DB2.
Set the parameters inside the connection string to match your database.

Then adapt some example in the OleDbConnection or OleDbRataReader classes to
your needs:
http://msdn.microsoft.com/library/en...ClassTopic.asp
http://msdn.microsoft.com/library/en...ClassTopic.asp

At this point you should have an OleDbDataReader instance containing the
values from the select. Read these values into a
System.Collections.Specialized.StringCollection:
http://msdn.microsoft.com/library/en...ClassTopic.asp

Then use the method CopyTo to copy the values into a string array:
http://msdn.microsoft.com/library/en...opyToTopic.asp

Hope this helps
Martin
"Antoni Massó Mola" <am****@triliumsoftware.com> wrote in message
news:eI**************@TK2MSFTNGP11.phx.gbl...
Hi,

I need to connect to a DB2 database, make a select * from table where like = 'somevalue'.

Then I need to copy thos values into a string array.

Any ideas?

Thanks

Nov 18 '05 #2
Go to www.connectionstrings.com and take one of the suggested ones for DB2.
Set the parameters inside the connection string to match your database.

Then adapt some example in the OleDbConnection or OleDbRataReader classes to
your needs:
http://msdn.microsoft.com/library/en...ClassTopic.asp
http://msdn.microsoft.com/library/en...ClassTopic.asp

At this point you should have an OleDbDataReader instance containing the
values from the select. Read these values into a
System.Collections.Specialized.StringCollection:
http://msdn.microsoft.com/library/en...ClassTopic.asp

Then use the method CopyTo to copy the values into a string array:
http://msdn.microsoft.com/library/en...opyToTopic.asp

Hope this helps
Martin
"Antoni Massó Mola" <am****@triliumsoftware.com> wrote in message
news:eI**************@TK2MSFTNGP11.phx.gbl...
Hi,

I need to connect to a DB2 database, make a select * from table where like = 'somevalue'.

Then I need to copy thos values into a string array.

Any ideas?

Thanks

Nov 18 '05 #3
Antoni -

After you make your connection, you could do the following:

Dim dt As DataTable
Dim al As New ArrayList(ds.Tables(0).Rows.Count)
dt = ds.Tables(0)
Dim i As Int32
For i = 0 To dt.Rows.Count - 1
al.Add(dt.Rows(i)(0))
Next
Dim s As String()
s = al.ToArray(GetType(String))

In this fragment ds would be your DataSet.

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 18 '05 #4
Antoni -

After you make your connection, you could do the following:

Dim dt As DataTable
Dim al As New ArrayList(ds.Tables(0).Rows.Count)
dt = ds.Tables(0)
Dim i As Int32
For i = 0 To dt.Rows.Count - 1
al.Add(dt.Rows(i)(0))
Next
Dim s As String()
s = al.ToArray(GetType(String))

In this fragment ds would be your DataSet.

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 18 '05 #5

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

Similar topics

4
by: Zion Zadik | last post by:
Dear all, I have a set of c# data classes which i need to fill their data from xml files. serialization looks to be the best way to accomplish this task. Since the data classes are compiled and...
71
by: ROSY | last post by:
1. How would you use the functions memcpy(), memset(), memmove()?
5
by: jab3 | last post by:
(again :)) Hello everyone. I'll ask this even at risk of being accused of not researching adequately. My question (before longer reasoning) is: How does declaring (or defining, whatever) a...
16
by: TTroy | last post by:
I FOUND MAJOR ERRORS in K&R2 (making it almost useless for the herein mentioned topics). K&R2 Section 5.9 Pointers vs. Multidimension Arrays starts of like this... "Newcomers to C are...
9
by: niclane | last post by:
Hi, I was reading section 5.5 of Ritchie and Kernighan and saw the following: " ..... char amessage = "now is the time"; char *pmessage = "now is the time";
23
by: arnuld | last post by:
i was doing exercise 4.3.1 - 4.29 of "C++ Primer 4/e" where authors, with "run-time shown", claim that C++ Library strings are faster than C-style character strings. i wrote the same programme in...
8
by: arnuld | last post by:
i have created a solutions myself. it compiles without any trouble and runs but it prints some strange characters. i am not able to find where is the trouble. ...
12
by: arnuld | last post by:
this is exercise 2-3 from the mentioned section. i have created a solution for it but i see errors and i tried to correct them but still they are there and mostly are out of my head: ...
0
by: David Thompson | last post by:
On Wed, 09 Apr 2008 12:34:43 +0500, arnuld <arnVuld@ippiVmail.com> wrote: I think you've got the idea, but: - I would be careful about using 'equal'. Pointers and arrays are different things,...
13
by: Richard Heathfield | last post by:
arnuld said: What do you think that line does? For my own part, I can make no sense whatsoever out of it. -- Richard Heathfield <http://www.cpax.org.uk> Email: -http://www. +rjh@ Google...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.