Solved

another way  of structuring the sqlcommand if parameter is an OUTPUT

Posted on 2016-10-05
1
26 Views
Last Modified: 2016-10-07
Here is one way to code a class if a parameter passed is an OUTPUT

1. new SqlParameter("@NewID", SqlDbType.Int) {DbType = DbType.Int32, Direction = ParameterDirection.Output }

however my current code is structured this way...
2. myCommand.Parameters.Add(new sqlParameter("@lastupdated", _lastupdated));

I want to add the output parameter code underneath with the same code style  rather than this  
"new SqlParameter("@NewID", SqlDbType.Int) {DbType = DbType.Int32, Direction = ParameterDirection.Output }"

how will I add the Direction and Parameter definition using that style of coding like #2?
0
Comment
Question by:zachvaldez
1 Comment
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 41830121
Hi zachvaldez;

There is no way that I know of to feed the direction parameter as a parameter to the constructor. First create the parameter and supply that to your line 2 as shown below.
' Add the input parameter and set its properties.
Dim parameter As New SqlParameter()
parameter.ParameterName = "@lastupdated"
parameter.SqlDbType = SqlDbType.DateTime
parameter.Direction = ParameterDirection.Input
parameter.Value = _lastupdated

' Add the parameter to the Parameters collection.
myCommand.Parameters.Add(parameter)

Open in new window

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

13 Experts available now in Live!

Get 1:1 Help Now