Solved

Trouble with datasets when updating stored procedures with output parms.

Posted on 2012-03-24
2
352 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
Comment Utility
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
Comment Utility
Thank you.  I forget that OTUPUT to Sequel means in and out.  Unlike Oracle and Sybase.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

744 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

15 Experts available now in Live!

Get 1:1 Help Now