Return values from VB.net component - Novice Question 
Author Message
 Return values from VB.net component - Novice Question

HI,

I am trying to return 2 output parameters from SQL server via a vb.net /
asp.net component, I have verified that the stored procedure is returning
the two values that I expect to see, however I am unsure of the syntax I
need to use in order to see it on the web form I can return one parameter
customerId I just don't know how to return both at the same time.

I have included the code below, if someone has any ideas I would be most
greatful.

Sean

function call in webform code behind page-----
Dim LoginCustomer As shopsmart.Customers = New shopsmart.Customers()

Dim customerId As String =
LoginCustomer.Login(Trim(UCase(txtUserName.Text)),
Trim(UCase(txtPassword.Text)))

Message.Text = customerId.ToString

Message1.Text = RetVal.ToString

Component code---

Public Function Login(ByVal email As String, ByVal password As String) As
String

' Create Instance of Connection and Command Object

Dim myConnection As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim myCommand As SqlCommand = New SqlCommand("CustomerLogin", myConnection)

' Mark the Command as a SPROC

myCommand.CommandType = CommandType.StoredProcedure

' Add Parameters to SPROC


SqlDbType.NVarChar, 300)

parameterEmail.Value = email

myCommand.Parameters.Add(parameterEmail)


SqlDbType.NVarChar, 10)

parameterPassword.Value = password

myCommand.Parameters.Add(parameterPassword)


SqlDbType.VarChar, 300)

parameterRetVal.Value = ParameterDirection.Output

myCommand.Parameters.Add(parameterRetVal)


SqlDbType.Int, 8)

parameterCustomerID.Direction = ParameterDirection.Output

myCommand.Parameters.Add(parameterCustomerID)

Try

myConnection.Open()

Catch XcpInvOp As System.Exception

Finally

myCommand.ExecuteNonQuery()

myConnection.Close()

myConnection.Dispose()

myConnection = Nothing

End Try

Dim customerId As Integer = CInt(parameterCustomerID.Value)

Dim RetVal As String = CStr(parameterRetVal.Value)

If customerId = 0 Then

Return Nothing

' Return RetVal

' Return customerId.ToString()

Else

Return customerId.ToString()

Return RetVal.ToString()

End If

End Function



Thu, 01 Dec 2005 09:44:07 GMT  
 Return values from VB.net component - Novice Question
Your clock is wrong!

Regards,
Herfried K. Wagner
--
MVP VB Classic, VB .NET
http://www.mvps.org/dotnet



Thu, 01 Dec 2005 06:47:43 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Unable to return ouput parameters to VB.net component - novice question

2. problem using component with asp page -- result of function not returned, instead original value returned

3. Main report value<-pass/return->subReport values (ActiveX Designer Component 6.0)

4. Returning Dataset to ASP.NET from .NET Component / Business Object Serialization

5. VB.NET Function Return Values

6. How to test for a NULL return value from FindByValue in vb.net

7. Returning Values from SP with VB.NET

8. Returning values from SP with VB.NET

9. Question from VBA novice re True and False values in VBA code for Word97

10. How To: Return more than a single value from Script Component methods - accessing thru VC++

11. vb .net novice please help

12. debugging vb.net upgraded component in asp.net

 

 
Powered by phpBB® Forum Software