Solved

Trouble with datasets when updating stored procedures with output parms.

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
disk usage reporting tools 27 51
Upgrading to SQL Server 2015 Express 2 30
ASP.NET Built-In Report Creator / Viewer 5 19
SQL- GROUP BY 4 22
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…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

761 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