Welcome Guest!

If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:

  • Receive Fast Advice
  • Learn Programming Languages
  • Get Professional Website Reviews
  • Quick Troubleshooting Assistance

> Using String.join()

This is a discussion on Using String.join(), within the ASP/.NET section. This forum and the thread "Using String.join()" are both part of the Programming Your Website category.

 
Reply to this topicStart new topic
> Using String.join()
karinne
post May 9 2008, 12:20 PM
Post #1


Co-Founder
******

Group: Co-Founders
Posts: 2,470
Joined: 13-February 08
From: Squeezin'
Member No.: 2



I'm trying to use the String.Join() to get an array to form 1 string

CODE

Dim arrSite As String = {"Hello", "BUILDING_NAME", "BUILDING_UNIT_IDENTIFIER", "DLVRY_INSTLTN_QUALIFIER_NAME", _
"ROUTE_SERVICE_NUMBER", "POSTAL_BOX_NUMBER", "STREET_NUMBER"}

strDisplayMember = String.Join(" ", CType(arrSite, String()))


But I get a blue squigly line under arrSite saying "Array initializers are valid only for arrays, but the type of 'arrSite' is 'String'"

Ok so .. if I change that to dim arrSite As Array, I still get a squigly line and it says "Array initializers are valid only for arrays, but the type of 'arrSite' is 'System.Array'"

?!? scratch_one-s_head.gif


--------------------
The Squeeze Store is now OPEN! Come on in and grab something!

a web design portfolio | web non-sense
I'm also on: del.icio.us | flickr | virb | facebook | twitter
The Web Squeeze is also on: virb | facebook | stumbleupon - JOIN IN!
Go to the top of the page
 
+Quote Post
karinne
post May 9 2008, 01:30 PM
Post #2


Co-Founder
******

Group: Co-Founders
Posts: 2,470
Joined: 13-February 08
From: Squeezin'
Member No.: 2



Bah... I forgot to put

Dim arrSite(10) As String tongue.gif


--------------------
The Squeeze Store is now OPEN! Come on in and grab something!

a web design portfolio | web non-sense
I'm also on: del.icio.us | flickr | virb | facebook | twitter
The Web Squeeze is also on: virb | facebook | stumbleupon - JOIN IN!
Go to the top of the page
 
+Quote Post
Antti
post May 9 2008, 01:32 PM
Post #3


Rapid Squeezer
****

Group: Members
Posts: 222
Joined: 15-February 08
From: Finland
Member No.: 139



Oh my how odd VB looks after six months with C# smile.gif Anyways... I think it needs to be something like this:

CODE
Dim arrSite() As String
arrSite = new String() {"Hello", "BUILDING_NAME", "BUILDING_UNIT_IDENTIFIER", "DLVRY_INSTLTN_QUALIFIER_NAME", _
"ROUTE_SERVICE_NUMBER", "POSTAL_BOX_NUMBER", "STREET_NUMBER"}


--------------------
anttisimonen.com - .NET developer

anttis.wordpress.com - Blog
Go to the top of the page
 
+Quote Post
Antti
post May 9 2008, 01:33 PM
Post #4


Rapid Squeezer
****

Group: Members
Posts: 222
Joined: 15-February 08
From: Finland
Member No.: 139



Oh, you were faster than me smile.gif Good that you got it solved.


--------------------
anttisimonen.com - .NET developer

anttis.wordpress.com - Blog
Go to the top of the page
 
+Quote Post
karinne
post May 9 2008, 02:03 PM
Post #5


Co-Founder
******

Group: Co-Founders
Posts: 2,470
Joined: 13-February 08
From: Squeezin'
Member No.: 2



Is there something else that basically does the same thing?!

Thing is I have all this data in a datatable (taken from the DB) and I just want to take certain fields from there and put in a string. Sort of the opposite of Trim()?


--------------------
The Squeeze Store is now OPEN! Come on in and grab something!

a web design portfolio | web non-sense
I'm also on: del.icio.us | flickr | virb | facebook | twitter
The Web Squeeze is also on: virb | facebook | stumbleupon - JOIN IN!
Go to the top of the page
 
+Quote Post
Antti
post May 9 2008, 02:36 PM
Post #6


Rapid Squeezer
****

Group: Members
Posts: 222
Joined: 15-February 08
From: Finland
Member No.: 139



If I understood you correctly, you have a database and you query it to get some stuff and then you want to assign those for string variables? If that's the case, DataReader is one possibility. Nowadays I usually just place the data in strongly typed dataset and then get what I need from there.


--------------------
anttisimonen.com - .NET developer

anttis.wordpress.com - Blog
Go to the top of the page
 
+Quote Post
karinne
post May 9 2008, 08:45 PM
Post #7


Co-Founder
******

Group: Co-Founders
Posts: 2,470
Joined: 13-February 08
From: Squeezin'
Member No.: 2



I have stuff in a db, then i query it and put it a datatable. From there, I want to be able to take certain fields in one row and concatenate it into a string. I don't have the stuff with me ... it's work stuff so I'll have to wait 'til monday biggrin.gif


--------------------
The Squeeze Store is now OPEN! Come on in and grab something!

a web design portfolio | web non-sense
I'm also on: del.icio.us | flickr | virb | facebook | twitter
The Web Squeeze is also on: virb | facebook | stumbleupon - JOIN IN!
Go to the top of the page
 
+Quote Post
Antti
post May 10 2008, 01:40 AM
Post #8


Rapid Squeezer
****

Group: Members
Posts: 222
Joined: 15-February 08
From: Finland
Member No.: 139



Then the datareader or dataset approach works fine. Dataset approach is a bit more work but has its advantages in the end. You can use datareader for now.


--------------------
anttisimonen.com - .NET developer

anttis.wordpress.com - Blog
Go to the top of the page
 
+Quote Post
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   3 Marc 62 8th April 2008 - 08:48 AM
Last post by: Marc
No New Posts   1 paintingtheweb 122 15th April 2008 - 03:19 PM
Last post by: Rakuli
No New Posts   9 unitedcraig 152 11th June 2008 - 02:18 AM
Last post by: unitedcraig