Solved

another way  of structuring the sqlcommand if parameter is an OUTPUT

Posted on 2016-10-05
1
36 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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