Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
public string[] GetEmployeerid()
        {
            String strConnection = ConfigurationManager.ConnectionStrings["MyConsString"].ConnectionString;
            SqlConnection conn = new SqlConnection(strConnection);
            SqlCommand cmd = new SqlCommand("select * from Employeertable ", conn);
            conn.Open();
Posted 31-Dec-12 20:21pm
Edited 1-Jan-13 0:46am
v2
Comments
Sergey Alexandrovich Kryukov at 1-Jan-13 2:23am
   
Who told you that you need a string array?
—SA
dhritirao1221 at 1-Jan-13 2:49am
   
some one suggested me to do like that.
Aman.A at 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
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 6,631
1 Sergey Alexandrovich Kryukov 6,345
2 CPallini 5,230
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web02 | 2.8.140921.1 | Last Updated 1 Jan 2013
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