Click here to Skip to main content
12,999,845 members (50,323 online)
Rate this:
Please Sign up or sign in to vote.
See more:
public string[] GetEmployeerid()
            String strConnection = ConfigurationManager.ConnectionStrings["MyConsString"].ConnectionString;
            SqlConnection conn = new SqlConnection(strConnection);
            SqlCommand cmd = new SqlCommand("select * from Employeertable ", conn);
Posted 31-Dec-12 20:21pm
Updated 1-Jan-13 0:46am
Who told you that you need a string array?
dhritirao1221 1-Jan-13 2:49am
some one suggested me to do like that.
Aman.A 1-Jan-13 6:29am
Looks like that "someone" has never heard of DataSet or List or any other advanced collections .NET has to offer. Unless, you intend to call this code via a service call for an AutoCompleteExtender control but even then the signature would be wrong.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You have written half the code. You should buy a book and read it, not take random suggestions from people. cmd.ExecuteQuery will return a dataset, which is a perfectly valid data source for a data driven control. If you need a string array, you need to pull the data you want out of the data set, but you should still have known how to run this SQL from the many, many articles that exist on this site and online.

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
Web02 | 2.8.170624.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2017
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