Help with Return value
-
hello i have folowing function
Public Shared Function Save(ByVal myContactInfo As ContactInfo) As Integer
Dim result As Integer = 0
' Using
Dim myConnection As SqlConnection = New SqlConnection(AppConfiguration.ConnectionString)
Try
Dim myCommand As SqlCommand = New SqlCommand("JobsDb_ContactInfo_InsertUpdateSingleItem", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
If myContactInfo.UserID = -1 Then
myCommand.Parameters.AddWithValue("@Userid", DBNull.Value)
Else
myCommand.Parameters.AddWithValue("@Userid", myContactInfo.UserID)
End If
myCommand.Parameters.AddWithValue("@UserName", myContactInfo.UserName)
myCommand.Parameters.AddWithValue("@Title", myContactInfo.Title)
myCommand.Parameters.AddWithValue("@FirstName", myContactInfo.FirstName)
myCommand.Parameters.AddWithValue("@LastName", myContactInfo.LastName)
myCommand.Parameters.AddWithValue("@Email", myContactInfo.Email)
If String.IsNullOrEmpty(myContactInfo.StreetAddress1) Then
myCommand.Parameters.AddWithValue("@StreetAddress1", DBNull.Value)
Else
myCommand.Parameters.AddWithValue("@StreetAddress1", myContactInfo.StreetAddress1)
End IfIf String.IsNullOrEmpty(myContactInfo.StreetAddress2) Then myCommand.Parameters.AddWithValue("@StreetAddress2", DBNull.Value) Else myCommand.Parameters.AddWithValue("@StreetAddress2", myContactInfo.StreetAddress2) End If If String.IsNullOrEmpty(myContactInfo.ZiporPost) Then myCommand.Parameters.AddWithValue("@ZipOrPost", DBNull.Value) Else myCommand.Parameters.AddWithValue("@ZipOrPost", myContactInfo.ZiporPost) End If myCommand.Parameters.AddWithValue("@CountryId", myContactInfo.CountryID) myCommand.Parameters.AddWithValue("@StateId", myContactInfo.StateID) myCommand.Parameters.AddWithValue("@city", myContactInfo.City) If String.IsNullOrEmpty(myContactInfo.PrimaryPhone) Then myCommand.Parameters.AddWithValue("@PrimaryPhone", DBNull.Value) Else
-
hello i have folowing function
Public Shared Function Save(ByVal myContactInfo As ContactInfo) As Integer
Dim result As Integer = 0
' Using
Dim myConnection As SqlConnection = New SqlConnection(AppConfiguration.ConnectionString)
Try
Dim myCommand As SqlCommand = New SqlCommand("JobsDb_ContactInfo_InsertUpdateSingleItem", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
If myContactInfo.UserID = -1 Then
myCommand.Parameters.AddWithValue("@Userid", DBNull.Value)
Else
myCommand.Parameters.AddWithValue("@Userid", myContactInfo.UserID)
End If
myCommand.Parameters.AddWithValue("@UserName", myContactInfo.UserName)
myCommand.Parameters.AddWithValue("@Title", myContactInfo.Title)
myCommand.Parameters.AddWithValue("@FirstName", myContactInfo.FirstName)
myCommand.Parameters.AddWithValue("@LastName", myContactInfo.LastName)
myCommand.Parameters.AddWithValue("@Email", myContactInfo.Email)
If String.IsNullOrEmpty(myContactInfo.StreetAddress1) Then
myCommand.Parameters.AddWithValue("@StreetAddress1", DBNull.Value)
Else
myCommand.Parameters.AddWithValue("@StreetAddress1", myContactInfo.StreetAddress1)
End IfIf String.IsNullOrEmpty(myContactInfo.StreetAddress2) Then myCommand.Parameters.AddWithValue("@StreetAddress2", DBNull.Value) Else myCommand.Parameters.AddWithValue("@StreetAddress2", myContactInfo.StreetAddress2) End If If String.IsNullOrEmpty(myContactInfo.ZiporPost) Then myCommand.Parameters.AddWithValue("@ZipOrPost", DBNull.Value) Else myCommand.Parameters.AddWithValue("@ZipOrPost", myContactInfo.ZiporPost) End If myCommand.Parameters.AddWithValue("@CountryId", myContactInfo.CountryID) myCommand.Parameters.AddWithValue("@StateId", myContactInfo.StateID) myCommand.Parameters.AddWithValue("@city", myContactInfo.City) If String.IsNullOrEmpty(myContactInfo.PrimaryPhone) Then myCommand.Parameters.AddWithValue("@PrimaryPhone", DBNull.Value) Else
What is your stored proc returning?
only two letters away from being an asset
-
What is your stored proc returning?
only two letters away from being an asset
its
ALTER PROCEDURE [dbo].[JobsDb_ContactInfo_InsertUpdateSingleItem]
@Userid int , @UserName varchar(50), @Title varchar(50), @FirstName varchar(50) , @LastName varchar(50), @Email varchar(50), @StreetAddress1 Varchar(50), @StreetAddress2 Varchar(50), @ZiporPost varchar(40), @CountryId int, @StateId int, @City varchar(50), @PrimaryPhone varchar(50), @SecondaryPhone varchar(50), @WorkStatus smallint, @SHMyName char(1), @SHMyEmail char(1), @SHMyPhones char(1), @ActivityDate datetime AS DECLARE @ReturnValue int IF (@Userid IS NULL) -- New Item BEGIN INSERT INTO JobsDb\_ContactInformation (\[UserName\] , \[Title\], \[FirstName\] , \[LastName\] , \[Email\], \[StreetAddress1\], \[StreetAddress2\] , \[ZiporPost\] , \[CountryID\], \[StateId\], \[City\], \[PrimaryPhone\] , \[SecondaryPhone\], \[WorkStatus\], \[SHMyName\] , \[SHMyEmail\], \[SHMyPhones\], \[ActivityDate\]
)
VALUES
(
@UserName,
@Title,
@FirstName,
@LastName,
@Email,
@StreetAddress1,
@StreetAddress2,
@ZiporPost,
@CountryId,
@StateId,
@City,
@PrimaryPhone,
@SecondaryPhone,
@WorkStatus,
@SHMyName,
@SHMyEmail,
@SHMyPhones,
@ActivityDate
)SELECT @ReturnValue = SCOPE\_IDENTITY() END ELSE BEGIN UPDATE JobsDb\_ContactInformation SET \[UserName\] = @UserName, \[Title\] = @Title, \[FirstName\] = @FirstName, \[LastName\] = @LastName, \[Email\] = @Email, \[StreetAddress1\] = @StreetAddress1, \[StreetAddress2\] = @StreetAddress2, \[ZiporPost\] = @ZiporPost, \[CountryId\]= @CountryId, \[StateId\] = @StateId, \[City\] = @City, \[PrimaryPhone\] = @PrimaryPhone, \[SecondaryPhone\] = @SecondaryPhone, \[WorkStatus\]=@WorkStatus, \[SHMyName\] = @SHMyName, \[SHMyEmail\]=@SHMyEmail, \[SHMyPhones\]=@SHMyPhones, \[ActivityDate\]= @ActivityDate WHERE UserId = @Userid SELECT @ReturnValue = @Userid END IF (@@ERROR != 0) BEGIN RETURN -1 END ELSE BEGIN RETURN @ReturnValue END
appu