Solved

Trouble with datasets when updating stored procedures with output parms.

Posted on 2012-03-24
2
353 Views
Last Modified: 2012-03-25
I created the attached stored procedure for self learning and it has 4 output parms.

@NewOrderLine int OUTPUT ,
      @ReturnCode int OUTPUT,
      @ReturnMessage varchar(255) OUTPUT,
      @RowsChanged int OUTPUT

When I add a dataset to the WinForms project and choose option to build strongly typed data set over the stored procedure I get the warning shown in the attached word document.

My questions is can I write the SP to avoid this problem and still have output parms?
Or how can I write the C# code to use the generated dataset?  (I want to use the strongly typed set, I do not want to use a weakly defined dataset.)
 
My code is as follows.
NW_orderDetailsDataSetTableAdapters.OrderDetailSelectByOrderTableAdapter ta = new OrderDetailSelectByOrderTableAdapter();

NW_orderDetailsDataSet.OrderDetailSelectByOrderDataTable dsOrders = new NW_orderDetailsDataSet.OrderDetailSelectByOrderDataTable();

            ta.Fill(dsOrders, 10250);
            foreach (var dsOrder in dsOrders)
            {
                Debug.WriteLine(dsOrder.Quantity.ToString());
                dsOrder.Quantity += 1;
            }
            try
            {
                //this code throws the exeception that the output parms are not defined.
                int update = ta.Update(dsOrders);
                Debug.WriteLine(update.ToString());
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());
                Debug.WriteLine(e1.ToString());
                throw;
            }
NorthWindOrderDetailUpateScript.sql
steps-to-add-stronly-typed-datas.docx
0
Comment
Question by:wilfordrocks
2 Comments
 
LVL 24

Accepted Solution

by:
DBAduck - Ben Miller earned 500 total points
ID: 37761985
Because they are output parameters, you can assign them values of NULL

@NewOrderline int = NULL OUTPUT

But the warning is just telling you that the values in the DataSet will not be used in the calls.

Set default values for the OUTPUT parameters and see how it goes for you.
0
 

Author Closing Comment

by:wilfordrocks
ID: 37762674
Thank you.  I forget that OTUPUT to Sequel means in and out.  Unlike Oracle and Sybase.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

943 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now