?
Solved

DataAdapter, stored procedures and parameters

Posted on 2014-03-11
2
Medium Priority
?
69 Views
Last Modified: 2016-06-04
I have a few questions regarding stored procs and the SqlDataAdapter:

When I run the adapter's Update-method, I understand it will call the specified Insert-, Update- and Delete-commands where appropriate, based on the staus of the table's rows.
-If these commands are set to stored procedures, does it pass parameters for each column in the table with the correct values, or does it pass the table row in question?
-Do you have to specify all parameters manually, or does the adapter know which values to pass?
-Is it possible to make a sp for, let's say Insert, without defining parameters for each column? If you pass the table row the sp should know both column names and values (or not)?

What I actually try to achieve, is to have one Insert-, one Update- and one Delete-stored proc to work on all tables in my database. From wherever in my app where I have to do som data handling, I would call a data handler to prepare necessary parameters and values before running adapter.Update().
Impossible, bad approach or brilliant?
0
Comment
Question by:Klasen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 39920307
If you use stored procedures you need to define the SqlCommand/parameters manually, so you can pick and choose which columns you want to pass to the procedure.

What you are suggesting is possible, but not really recommended. Having a single stored procedure for all of your updates/inserts/deletes means that you will be relying on dynamic SQL, and you will lose the benefits of caching and optimization for individual queries.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question