how to access and display an output parameter

D

DC Gringo

I would like to know how to set an output parameter to a variable and output
it on a web form:

This didn't work:
Me.SqlSelectCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@gcLatest", System.Data.SqlDbType.Int,
4, System.Data.ParameterDirection.Output, False, CType(0, Byte), CType(0,
Byte), "", System.Data.DataRowVersion.Current, ???THEVARIABLE???))

<% = THEVARIABLE %>
 
G

Greg Burns

SqlSelectCommand.Parameters.Add("@gsLatest", SqlDbType.Int, 4).Direction =
ParameterDirection.Output
....
SqlSelectCommand.ExecuteNonQuery()
....
Dim i As Integer = CInt(SqlSelectCommand.Parameters("@gsLatest").Value)

Greg
 
D

Davide Vernole [MVP]

DC Gringo said:
I would like to know how to set an output parameter to a variable and
output it on a web form:

This didn't work:
Me.SqlSelectCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@gcLatest",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Output,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, ???THEVARIABLE???))

<% = THEVARIABLE %>

To access an output parameter:

Dim myOutPar As string =
Me.SqlSelectCommadn1.Parameters("@gcLates").Value.ToString()

Than you can use your variable as you like, for example in a Label:

Me.myLabel.Text = myOutPar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top