.NETGURU
output parameter values not displaying properly
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.adonet.

Post a new message to this list...

DC Gringo
I have a SQL Server stored procedure that outputs 4 parameters and a
recordset. They are outputting just fine in Query Analyzer, but come out as

[@gcLatestNav] = 1/1/0001
[@pubLatestNav] = 0
[@gcPreviousNav] = 1/1/0001
[@pubPreviousNav] = 0

-- Here is my stored procedure --

Create Procedure fn3MainNav

@gcLatestNav int = 1 output,
@pubLatestNav smalldatetime = '5/5/2002' output,
@gcPreviousNav int = 1 output,
@pubPreviousNav smalldatetime = '5/5/2002' output

as

SELECT TOP 1
@gcLatestNav = gc1.gc_id,
@pubLatestNav = gc1.published

SELECT TOP 1
@gcPreviousNav = gc1.gc_id,
@pubPreviousNav = gc1.published
FROM general_content gc1

-- Here's the relevant section of my .aspx code --

<% = pubLatestNav %>
<% = gcLatestNav %>
<% = pubPreviousNav %>
<% = gcPreviousNav %>

-- Here's my code behind --

Public Class mainNav
Inherits System.Web.UI.UserControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.SqlCommand1 = New System.Data.SqlClient.SqlCommand
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString =
"server=myserver_2;database=mdb;uid=sa;pwd=mypwd;"
'
'SqlCommand1
'
Me.SqlCommand1.CommandText = "fn3MainNav"
Me.SqlCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlCommand1.Connection = Me.SqlConnection1
Me.SqlCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@gcLatestNav",
System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Output, False,
CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current,
Nothing))
Me.SqlCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@pubLatestNav",
System.Data.SqlDbType.SmallDateTime, 0,
System.Data.ParameterDirection.Output, False, CType(0, Byte), CType(0,
Byte), "", System.Data.DataRowVersion.Current, Nothing))
Me.SqlCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@gcPreviousNav",
System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Output, False,
CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current,
Nothing))
Me.SqlCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@pubPreviousNav",
System.Data.SqlDbType.SmallDateTime, 0,
System.Data.ParameterDirection.Output, False, CType(0, Byte), CType(0,
Byte), "", System.Data.DataRowVersion.Current, Nothing))
End Sub

Public gcLatestNav As Integer
Public pubLatestNav As String
Public gcPreviousNav As Integer
Public pubPreviousNav As String

Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Protected WithEvents SqlCommand1 As System.Data.SqlClient.SqlCommand

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
gcLatestNav = Me.SqlCommand1.Parameters("@gcLatestNav").Value
pubLatestNav =
FormatDateTime(Me.SqlCommand1.Parameters("@pubLatestNav").Value,
DateFormat.ShortDate)
gcPreviousNav = Me.SqlCommand1.Parameters("@gcPreviousNav").Value
pubPreviousNav =
FormatDateTime(Me.SqlCommand1.Parameters("@pubPreviousNav").Value,
DateFormat.ShortDate)

End Sub

End Class

from database right but showing

--
_____
DC G

Reply to this message...
 
    
William \(Bill\) Vaughn
I see where you're creating the Command object, but not where it's executed.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"DC Gringo" <Click here to reveal e-mail address> wrote in message
news:OI%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
DC Gringo
I got it, thanks Bill...

I was missing

SqlConnection1.Open()

SqlCommand1.ExecuteNonQuery()

SqlConnection1.Close()

"William (Bill) Vaughn" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> I see where you're creating the Command object, but not where it's
executed.
[Original message clipped]

Reply to this message...
 
    
William \(Bill\) Vaughn
details ... details... ;)

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"DC Gringo" <Click here to reveal e-mail address> wrote in message
news:%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.Data.CommandType
System.Data.DataRowVersion
System.Data.ParameterDirection
System.Data.SqlClient.SqlCommand
System.Data.SqlClient.SqlConnection
System.Data.SqlClient.SqlParameter
System.Data.SqlDbType
System.EventArgs
System.Object
System.Web.UI.UserControl




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification