How to get records from a database?



How to get records from a database?..

Answer / Saurabh Kumar

To retrieve records from a database in C#.NET, you can use ADO.NET classes like SqlCommand, SqlDataReader, or DataTable. Here's an example using SqlCommand and SqlDataReader: SqlConnection connection = new SqlConnection(connectionString); SqlCommand command = new SqlCommand("SELECT * FROM table", connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { // process each record here }

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Dot Net WindowsForms Interview Questions

What are windows based applications examples?

1 Answers  


Is typeform free?

1 Answers  


Name the class to be inherited for creating a custom control.

1 Answers  


Which controls can not be placed in MDI ?

2 Answers  


Which event occurs when a user drags an item in a treeview or listview control?

1 Answers  


which Property is used to count no. of items in a combobox?

3 Answers  


What is form and meaning?

1 Answers  


how print PGL by XML

1 Answers   Bank Of America, Wipro,


What are the different types of JOINs in SQL Server?

3 Answers   Arctern,


Explain the new events in textbox that has been included in vb?

1 Answers  


How do you customize the column content inside the datagrid?

2 Answers  


How do you hide the columns in datagrid?

2 Answers  


Categories