Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6610487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:50:49+00:00 2026-05-25T19:50:49+00:00

My code is construct to read data in a datagridView named (dg) from my

  • 0

My code is construct to read data in a datagridView named (dg) from my database.

Its actually work well whit a SqlDataAdapter.

First Is it a good idea to change my SqlDataAdapter for a SqlCommand ?

If YES

I want to use this for change my SqlDataAdapter.

//SqlCommand cmd = new SqlCommand("Command String", con);
//SqlDataReader readdata;

CODE

SqlConnection con = new SqlConnection(dc.Con);

SqlDataAdapter da = new SqlDataAdapter();
con.Open();
da.SelectCommand = new SqlCommand("SELECT * FROM tblContacts", con);
DataTable dt = new DataTable();
da.Fill(dt);
con.Close();

dg.DataSource = dt;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:50:49+00:00Added an answer on May 25, 2026 at 7:50 pm

    I typically use the DataAdapter for data access when I need to do data-binding to controls. It’s very convenient and efficient in those scenarios. Otherwise, I use the Command objects directly. Performance-wise, I’m inclined to agree w/ punzki. There shouldn’t be much difference between the two.

    http://msforums.ph/forums/p/9057/9057.aspx

    Actually, from what I remember, SqlDataAdapter uses SqlDataReader to retrieve records. So It’s always good to use SQLDataReader when you’re going to just retrieve data from the backend. But if you’re going to retrieve data and then update (insert, update, delete) data later on, then it’s better to use SqlDataAdapter. I think it’s more efficient that way.

    http://msforums.ph/forums/t/29256.aspx

    There IS an effect on performance.

    SqlDataReader is no doubt faster than a SqlDataAdapter as the DataReader reads data in a forward only mode and you can get a specific type of value returned back to you, such as a string or int etc… however with the SqlDataAdapter, it will fill a datatable or dataset will records it finds in your select statement, taking with it the correct value type for the columns and is a disconnected representation of in memory database and is ideal and easier to use if you are going to show large amounts of records to a binding source, as with a SqlDataReader, it is not possible but to only obtain a value for a column you specify per row.

    The SqlDataAdapter also allows you to Update, Delete or Insert rows into the Dataset/DataTable which is an advantage and will execute the appropriate command, if you implemented it correctly, based on how the rows were modified in the Dataset/DataTable.

    SqlDataAdapter is expensive compared to a fast forward read on the SqlDataReader, and has more advantages but entirely depends on your solution and what you require.

    You are stating that you are going to show alot of records, whilst that is all very well, it would be even better for the benefit of the performance and memory usage to only obtain records that you require to be shown and a SqlDataAdapter would be suitable for this also but still you are required to select records which are the ones you will most likely show to the user, either by input search criteria, or perhaps by paging.

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/c2d762fd-f4a0-4875-8bb8-42f7480e97c8/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following code (from Bluetooth Chat sample app) to read the incoming
I want to 'construct' (read: malloc and memset) my hashtable in c. To do
I need an Android application which should be able to fetch data from the
I want to ship static read-only data for use in my Core Data model.
I'm trying to read a XmlReader into a XDocument //GetContentStructureReader() retrieves the reader from
I have this PHP class, whose purpose is to fetch some configuration data from
I'm in the process of porting some code from Linux to Mac OS X.
I'm creating a multi-tenant Asp.Net MVC 3 Web app, and using EF4.1 code first
Well I have a problem reading the JSON data in jQuery, which is outputted
I'm using PHP from the command line and I'm trying to embed data into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.