Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
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
Updated 1-Jan-13 0:46am
v2
Comments
Sergey Alexandrovich Kryukov 1-Jan-13 2:23am    
Who told you that you need a string array?
—SA
Dhritirao's 1-Jan-13 2:49am    
some one suggested me to do like that.
I.explore.code 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

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900