hey, I have a datatable here, but I need to make it into a string array. how
do I do that? 15 60571
roger_27 wrote:
hey, I have a datatable here, but I need to make it into a string array. how
do I do that?
You loop through the records and oncvert the values from each field in
the records into a string.
--
Göran Andersson
_____ http://www.guffa.com
Maybe some code like this will work for you. (You may have to check
for DBNulls or null in your table).
string[,] stringArray = new string[dataTable1.Rows.Count,
dataTable1.Columns.Count];
for(int row = 0; row < dataTable1.Rows.Count; ++row)
{
for(int col = 0; col < datatable1.Columns.Count; col++)
{
stringArray[row, col] = dataTable1.Rows[row][col].ToString();
}
}
===================
Clay Burch
Syncfusion, Inc.
Excellent. thanks for the help guys.
here is my solution
string connectionString = "Put Connection String Here";
//make datatable
DataTable tables = new DataTable("Tables");
//this code gets a list of all the tables in the database and puts them in a
DataTable.
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = connection.CreateCommand();
command.CommandText = "select table_name as Name from
INFORMATION_SCHEMA.Tables where TABLE_TYPE = 'BASE TABLE'";
connection.Open();
tables.Load(command.ExecuteReader(CommandBehavior. CloseConnection));
}
//make the array list to use
ArrayList arr = new ArrayList();
//put all the items in each row into a new item in the arraylist.
//since the dataTable is 1 item per row, it cant be done this way
foreach (DataRow dr in tables.Rows)
{
arr.Add(dr);
}
now each table in my database can be accessed by idex number in the arraylist
MessageBox.show("Here is my 3rd table in the database " + arr[2].ToString());
actually.. heres one that works better. it stores them as straight strings so
you can go
if(arraylist[0].tostring == "wow")
{
code
}
//make data table object called Tables
DataTable tables = new DataTable("Tables");
//this code takes every table in the data base and puts them in a data table
1 column big, with each
//row being a table
using (SqlConnection connection = new SqlConnection(Connection string or
Connection String Variable here!))
{
SqlCommand command = connection.CreateCommand();
command.CommandText = "select table_name as Name from
INFORMATION_SCHEMA.Tables where TABLE_TYPE = 'BASE TABLE'";
connection.Open();
tables.Load(command.ExecuteReader(CommandBehavior. CloseConnection));
}
//make an arraylist
ArrayList arTables = new ArrayList();
//go through each row of data, which is 1 column wide
//and add it to the array list!
foreach (DataRow dr in tables.Rows)
{
arTables.Add(dr.ItemArray[0].ToString());
}
Roger,
Just a peanut, but what you are using is not a string array. It is far away
from that.
It is an arraylist filled with datarows (not even items).
Cor
"roger_27" <ro*****@discussions.microsoft.comschreef in bericht
news:FA**********************************@microsof t.com...
Excellent. thanks for the help guys.
here is my solution
string connectionString = "Put Connection String Here";
//make datatable
DataTable tables = new DataTable("Tables");
//this code gets a list of all the tables in the database and puts them in
a
DataTable.
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = connection.CreateCommand();
command.CommandText = "select table_name as Name from
INFORMATION_SCHEMA.Tables where TABLE_TYPE = 'BASE TABLE'";
connection.Open();
tables.Load(command.ExecuteReader(CommandBehavior. CloseConnection));
}
//make the array list to use
ArrayList arr = new ArrayList();
//put all the items in each row into a new item in the arraylist.
//since the dataTable is 1 item per row, it cant be done this way
foreach (DataRow dr in tables.Rows)
{
arr.Add(dr);
}
now each table in my database can be accessed by idex number in the
arraylist
MessageBox.show("Here is my 3rd table in the database " +
arr[2].ToString());
yeah I know. but I realized that I need something dynamic because I will
never know how big to make them
you know.. if you just used ADO classic instead of this ADO.net _CRAP_
then you could have 2 recordsets open; via the same connection-- at
the same time
ADO.net is crap sorry dog; it's all going to change again this summer
with Visual Fred 3.0
On Mar 13, 8:11 am, roger_27 <roge...@discussions.microsoft.com>
wrote:
yeah I know. but I realized that I need something dynamic because I will
never know how big to make them
PFC Sadr wrote:
you know.. if you just used ADO classic instead of this ADO.net _CRAP_
then you could have 2 recordsets open; via the same connection-- at
the same time
Which is keeping two connections open behind the scene.
ADO.net is crap sorry dog; it's all going to change again this summer
with Visual Fred 3.0
On Mar 13, 8:11 am, roger_27 <roge...@discussions.microsoft.com>
wrote:
>yeah I know. but I realized that I need something dynamic because I will never know how big to make them
--
Göran Andersson
_____ http://www.guffa.com
I'm not positive I beleive you dog
-Todos
On Mar 13, 1:30 pm, Göran Andersson <g...@guffa.comwrote:
PFC Sadr wrote:
you know.. if you just used ADO classic instead of this ADO.net _CRAP_
then you could have 2 recordsets open; via the same connection-- at
the same time
Which is keeping two connections open behind the scene.
ADO.net is crap sorry dog; it's all going to change again this summer
with Visual Fred 3.0
On Mar 13, 8:11 am, roger_27 <roge...@discussions.microsoft.com>
wrote:
yeah I know. but I realized that I need something dynamic because I will
never know how big to make them
--
Göran Andersson
_____http://www.guffa.com
C# doesn't support strings. sorry
it's just old-fashioned; when we invented C# we wanted it to be
REVOLUTIONARY
so we called them all cSharpStrings
-Todos
On Mar 12, 3:34 pm, roger_27 <roge...@discussions.microsoft.com>
wrote:
hey, I have a datatable here, but I need to make it into a string array. how
do I do that?
I am not positive that I care if you "beleive" me or not.
Todos Menos [MSFT] wrote:
I'm not positive I beleive you dog
-Todos
On Mar 13, 1:30 pm, Göran Andersson <g...@guffa.comwrote:
>PFC Sadr wrote:
>>you know.. if you just used ADO classic instead of this ADO.net _CRAP_ then you could have 2 recordsets open; via the same connection-- at the same time
Which is keeping two connections open behind the scene.
>>ADO.net is crap sorry dog; it's all going to change again this summer with Visual Fred 3.0 On Mar 13, 8:11 am, roger_27 <roge...@discussions.microsoft.com> wrote: yeah I know. but I realized that I need something dynamic because I will never know how big to make them
-- Göran Andersson _____http://www.guffa.com
--
Göran Andersson
_____ http://www.guffa.com
ok, smarty pants
what defines a new connection
because from where im standing; they have the same SPID; so thus they
are the same connection
On Mar 13, 3:11 pm, Göran Andersson <g...@guffa.comwrote:
I am not positive that I care if you "beleive" me or not.
Todos Menos [MSFT] wrote:
I'm not positive I beleive you dog
-Todos
On Mar 13, 1:30 pm, Göran Andersson <g...@guffa.comwrote:
PFC Sadr wrote: you know.. if you just used ADO classic instead of this ADO.net _CRAP_ then you could have 2 recordsets open; via the same connection-- at the same time
Which is keeping two connections open behind the scene.
>ADO.net is crap sorry dog; it's all going to change again this summer with Visual Fred 3.0 On Mar 13, 8:11 am, roger_27 <roge...@discussions.microsoft.com> wrote: yeah I know. but I realized that I need something dynamic because I will never know how big to make them
--
Göran Andersson
_____http://www.guffa.com
--
Göran Andersson
_____http://www.guffa.com
Hello Todos,
Let me tell you that you're a funny kind of idiot. Let me also say, to be
clear, that I'd much prefer it if you took your crap elsewhere.
Oliver Sturm
-- http://www.sturmnet.org/blog
I like his postings
at least Todos doesn't block people that disagree with him.
that is called CENSORSHIP and the USA should not stand for it
On Mar 14, 2:26 pm, "Oliver Sturm" <oli...@sturmnet.orgwrote:
Hello Todos,
Let me tell you that you're a funny kind of idiot. Let me also say, to be
clear, that I'd much prefer it if you took your crap elsewhere.
Oliver Sturm
--http://www.sturmnet.org/blog
"Oliver Sturm" <ol****@sturmnet.orgwrote in message
news:xn****************@msnews.microsoft.com...
Hello Todos,
Let me tell you that you're a funny kind of idiot. Let me also say, to be
clear, that I'd much prefer it if you took your crap elsewhere.
Oliver Sturm
-- http://www.sturmnet.org/blog
He's a troll. This is a new alias for him. He trolls over in the VB group
as aaronkempf, susiedba, dbahooker, larrylinson, and those are just the
ones I can remember.
Robin S. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jeff Johnson |
last post by:
Hi,
I've begun converting an ASP site over to .NET and I'm a novice at both the
new platform as well as C#.
I have a COM+ object that returns a string array when it is called. The
size of...
|
by: pagates |
last post by:
Hi All,
I have a need to create a generic DataTable using data in a 2D array of
strings (I do not have direct access to the database, and am given the data
via another program that I do not have...
|
by: Zordiac |
last post by:
How do I dynamically populate a string array?
I hope there is something obvious that I'm missing here
Option Strict On
dim s() as string
dim sTmp as string = "test"
dim i as integer
...
|
by: Lance |
last post by:
Hi All,
Suppose I have a dynamic string array
Dim sa(,) as string
I want to populate the first two columns of a datagrid control with the two
columns of sa. I want the third column of the...
|
by: Paulers |
last post by:
Hello all,
I have a string array with duplicate elements. I need to create a new
string array containing only the unique elements. Is there an easy way
to do this? I have tried looping through...
|
by: dllhell |
last post by:
Hi all,
Is there a way to make a string array from DataTable?
I wish to avoid for statement...
thanks in advance
|
by: Niyazi |
last post by:
Hi all,
What is fastest way removing duplicated value from string array using vb.net?
Here is what currently I am doing but the the array contains over 16000
items. And it just do it in 10 or...
|
by: twq |
last post by:
Hello
I would like to populate a 2-dimensional array with different
datatyps , 1. dimension is always a String, 2. dimension could be of
Typ Double or String.
What would be the better...
|
by: John Sitka |
last post by:
Hi,
I'm building a simple "look up" web method that would return
a table with 9 columns and a dynamic number of rows,
then I find out datatables cannot be serialized.
Not a big deal the .Net...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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...
| |