0

I am a newbie in VB.NET windows application development. Now I am referring an already developed application. In my reference project every data update is using a DataAdapter, first loading the data in the adapter then creating a new row that updates adapter. So, this method first fetches data then updates data. If we are using direct SQL commands there is only one database insert/update statement. Is there significant impact in between these two methods?

2 Answers 2

1

Is there significant impact in between these two methods?

That is a very general question, so the general answer is "It depends...". The overhead of creating and filling a DataAdapter will cost you something, but whether or not that is a significant cost will depend on factors like...

  • how much data is in the table(s) you are updating

  • how much information you are pulling into the DataAdapter

  • whether the database file is on a local drive or a network share

...and (perhaps) many other factors. The only way for you to know if there is a significant performance difference between the two approaches in your particular circumstances would be for you to run some tests and compare the results.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Gord. Now i am developing an application that works with database on the same machine. If it works perfectly, we needed to extend the usage of this application for many users over network with a network server machine. We can cosider the application environment in its extreme case with large amount of data over network share.I know its better to use SQL cammand for insert/update statement in this time. So its again leads us to use SQL command, there is no advantage of using Adapter method other than coding simplicity. im i right ?
@user2718241 The DataAdapter method can simplify your code somewhat, but it can also result in your losing some degree of control in how you interact with the database. For example, see the recent question here. Personally, I would tend to use my own SQL statements in most cases and only use a DataAdapter if it offered me some significant advantage, e.g., if I needed to pull a bunch of information into a DataTable, mess around with it, and then let "the system" manage all of the updates for me.
0

The latter option will be on the whole be faster, to my knowledge. The DataAdapter will as you suggest query for the data and load it into memory, before making any required updates. I would be extremely surprised however, if the DataAdapter updated all rows regardless of whether the row has changed - I should expect that it will only send the required SQL to the DBMS.

Running an update statement via SqlCommand circumvents querying for and loading the data, and dependent on your query will probably make the update to the DB itself in roundabout the same way.

The decision between the two depends entirely on context.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.