Click here to Skip to main content
11,934,783 members (47,099 online)
Rate this:
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
OriginalGriff 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 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
Please Sign up or sign in to vote.

Solution 1


Try this

DataTable DT=new DataTable();
string[] arr;
string StrArray = string.Join(",", (from DataRow row in DT.Rows select (string)row["DataTableColumnName"]).ToArray());
arr = StrArray.Split(',');
Rate this: bad
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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 13 Dec 2012
Copyright © CodeProject, 1999-2015
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