Solved

Trouble with datasets when updating stored procedures with output parms.

Posted on 2012-03-24
2
358 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
[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 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

739 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