Click here to Skip to main content
15,896,342 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to retrive the set of names which are stored in sql database
Can you send me the code in c# to retrive one of the column which is depend on where clause.
Posted

1 solution

Try the following code in which disconnected architecture is used.
Public DataSet GetData()
        {
            String connectionstring = "your connection string";
            using (SqlConnection connection = new SqlConnection(connectionstring))
            {
                if (connection.State == ConnectionState.Closed)
                    connection.Open();
                SqlCommand command = new SqlCommand("Select * from tablename where colName = value", connection);
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataSet ds = new DataSet();
                adapter.Fill(ds);
                if(connection.State == ConnectionState.Open)
                    connection.Close();
                return ds;
            }
        }


if the solutions is helful to you then pls accept the solution
 
Share this answer
 
v2

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