Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL database Server
Hi, please help me i want a method whose return type must be string[] and in that method i want to load columns values from sql server database,please help me with a sample snippet
Posted 13-Dec-12 5:45am
Comments
OriginalGriff at 13-Dec-12 10:46am
   
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
You need to tell us more about what kind of data you are getting from your database, and how you need it converted to a string array. Otherwise we have to guess, and that really isn't a good strategy!
Use the "Improve question" widget to edit your question and provide better information.
ryanb31 at 13-Dec-12 11:14am
   
Where are you stuck? There are a million ways to do this and it will depend on the classes you have.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
Try this
 
DataTable DT=new DataTable();
string[] arr;
if(DT.Rows.Count>0)
{
string StrArray = string.Join(",", (from DataRow row in DT.Rows select (string)row["DataTableColumnName"]).ToArray());
arr = StrArray.Split(',');
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Ya,there are many ways.1st u have to try google, it will explore u much better.
 
But u ask,so try->
 
String SourceData;  //to store data from column 
string[] strArr = new string[SourceData];
char[] splitchar = {' '};
strArr = str.Split(splitchar);
 
Here in strArr u will found o/p as u want.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Mathew Soji 334
1 Maciej Los 295
2 BillWoodruff 290
3 Afzaal Ahmad Zeeshan 257
4 DamithSL 225
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,045


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 13 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100