473,387 Members | 1,561 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,387 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
2 896
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
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 #3

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

Similar topics

3
by: Java script Dude | last post by:
Some programmers prefer to stay with native level data structures such as string arrays instead of using Object based data structures such as ArrayList. From and efficiency point of view. Are...
6
by: ASPfool | last post by:
Hello everyone, Please help me before I throw my computer out of the window: I'm working on a web application in classic ASP (vbscript), which is making calls to some webservices. The calls...
2
by: zlf | last post by:
Hi, This there any existing alorgithm in .NET that can extract the common element in two string arrays to another string array; usage: string a = { "1","2","3" }; string b = { "1" }; string...
2
by: Antoni Massó Mola | last post by:
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
9
by: jerry.upstatenyguy | last post by:
I am really stuck on this. I am trying to write a string array containing a "word" and a "definition" to a class called Entry. Ultimately this will end up in another class called dictionary. No,...
0
by: Caffiend | last post by:
Hello again! I am still having problems with the code under the title "newbie woes", but I have moved on for now to another exercise. The book has asked me to write a program that will use two...
1
by: Rick Knospler | last post by:
I am trying to convert a vb6 project to vb.net. The conversion worked for the most part except for the fixed length strings and fixed length string arrays. Bascially the vb6 programmer stored all...
8
by: rsaikamesh | last post by:
Hi All, In my c++ application, I need to use 60 string arrays with the size of 16. If I create this much of arrays, will the performance of my application be affected?
6
by: tshad | last post by:
I am looking for a way to combine 2 string arrays. I am trying to get a list of files from 2 directories and combine them: string strFiles; string strFiles2; strFiles =...
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
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
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...
0
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,...
0
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...

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.