Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Help with Return value

Help with Return value

Scheduled Pinned Locked Moved ASP.NET
help
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 4065472
    wrote on last edited by
    #1

    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 If

                If 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
    
    N 1 Reply Last reply
    0
    • M Member 4065472

      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 If

                  If 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
      
      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      What is your stored proc returning?


      only two letters away from being an asset

      M 1 Reply Last reply
      0
      • N Not Active

        What is your stored proc returning?


        only two letters away from being an asset

        M Offline
        M Offline
        Member 4065472
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups