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. Return value

Return value

Scheduled Pinned Locked Moved ASP.NET
databasehelp
6 Posts 4 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

    i have SAVE function and a stored procedure ("JobsDb_ContactInfo_InsertUpdateSingleItem" which return "returnValue" which is returned value integer of inserted UserId please help me get returned value UserID i am trying to get Profile.UserId =Returned value of stored procedure UserId This is the code i have in web form to save data If Not (Profile.UserId = -1) Then myContactInfo.UserID = Profile.UserId [ContactInfoManager].Save(myContactInfo) Else Dim result As Integer = ContactInfoManager.Save(myContactInfo) Profile.UserId = result ) End If this is the Save 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 myCommand.Parameters.AddWithValue("@Userid", UserId) Dim returnValue As DbParameter returnValue = myCommand.CreateParameter returnValue.Direction = ParameterDirection.ReturnValue myCommand.Parameters.Add(returnValue) myConnection.Open() myCommand.ExecuteNonQuery() result = Convert.ToInt32(returnValue.Value) myConnection.Close() Finally CType(myConnection, IDisposable).Dispose() End Try Return result End Function

    appu

    M P G 3 Replies Last reply
    0
    • M Member 4065472

      i have SAVE function and a stored procedure ("JobsDb_ContactInfo_InsertUpdateSingleItem" which return "returnValue" which is returned value integer of inserted UserId please help me get returned value UserID i am trying to get Profile.UserId =Returned value of stored procedure UserId This is the code i have in web form to save data If Not (Profile.UserId = -1) Then myContactInfo.UserID = Profile.UserId [ContactInfoManager].Save(myContactInfo) Else Dim result As Integer = ContactInfoManager.Save(myContactInfo) Profile.UserId = result ) End If this is the Save 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 myCommand.Parameters.AddWithValue("@Userid", UserId) Dim returnValue As DbParameter returnValue = myCommand.CreateParameter returnValue.Direction = ParameterDirection.ReturnValue myCommand.Parameters.Add(returnValue) myConnection.Open() myCommand.ExecuteNonQuery() result = Convert.ToInt32(returnValue.Value) myConnection.Close() Finally CType(myConnection, IDisposable).Dispose() End Try Return result End Function

      appu

      M Offline
      M Offline
      MrPlankton
      wrote on last edited by
      #2

      what is the error? how is it failing?

      MrPlankton

      M 1 Reply Last reply
      0
      • M Member 4065472

        i have SAVE function and a stored procedure ("JobsDb_ContactInfo_InsertUpdateSingleItem" which return "returnValue" which is returned value integer of inserted UserId please help me get returned value UserID i am trying to get Profile.UserId =Returned value of stored procedure UserId This is the code i have in web form to save data If Not (Profile.UserId = -1) Then myContactInfo.UserID = Profile.UserId [ContactInfoManager].Save(myContactInfo) Else Dim result As Integer = ContactInfoManager.Save(myContactInfo) Profile.UserId = result ) End If this is the Save 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 myCommand.Parameters.AddWithValue("@Userid", UserId) Dim returnValue As DbParameter returnValue = myCommand.CreateParameter returnValue.Direction = ParameterDirection.ReturnValue myCommand.Parameters.Add(returnValue) myConnection.Open() myCommand.ExecuteNonQuery() result = Convert.ToInt32(returnValue.Value) myConnection.Close() Finally CType(myConnection, IDisposable).Dispose() End Try Return result End Function

        appu

        P Offline
        P Offline
        pmarfleet
        wrote on last edited by
        #3

        Your question has nothing to do with ASP.NET. You should post it in either the VB.NET or SQL forum.

        Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

        1 Reply Last reply
        0
        • M Member 4065472

          i have SAVE function and a stored procedure ("JobsDb_ContactInfo_InsertUpdateSingleItem" which return "returnValue" which is returned value integer of inserted UserId please help me get returned value UserID i am trying to get Profile.UserId =Returned value of stored procedure UserId This is the code i have in web form to save data If Not (Profile.UserId = -1) Then myContactInfo.UserID = Profile.UserId [ContactInfoManager].Save(myContactInfo) Else Dim result As Integer = ContactInfoManager.Save(myContactInfo) Profile.UserId = result ) End If this is the Save 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 myCommand.Parameters.AddWithValue("@Userid", UserId) Dim returnValue As DbParameter returnValue = myCommand.CreateParameter returnValue.Direction = ParameterDirection.ReturnValue myCommand.Parameters.Add(returnValue) myConnection.Open() myCommand.ExecuteNonQuery() result = Convert.ToInt32(returnValue.Value) myConnection.Close() Finally CType(myConnection, IDisposable).Dispose() End Try Return result End Function

          appu

          G Offline
          G Offline
          Gandalf_TheWhite
          wrote on last edited by
          #4

          If i m not wrong then this is ASP.NET Section. Better u go through VB.Net Section, U will get Better response :|

          Believe Yourself™ :->™

          1 Reply Last reply
          0
          • M MrPlankton

            what is the error? how is it failing?

            MrPlankton

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

            it is giving no error but the data is not getting saved and the Profile.UserId is changing from -1 which is default to 0 please help me getting this solved as i m new to asp.net and the main Relational Key of all my database table is UserId and untill this is not solved i cant go any further...i have excecuted my stored procedure manualy and it is returning value of UserId but some how i made mistake in code os save function..

            appu

            M 1 Reply Last reply
            0
            • M Member 4065472

              it is giving no error but the data is not getting saved and the Profile.UserId is changing from -1 which is default to 0 please help me getting this solved as i m new to asp.net and the main Relational Key of all my database table is UserId and untill this is not solved i cant go any further...i have excecuted my stored procedure manualy and it is returning value of UserId but some how i made mistake in code os save function..

              appu

              M Offline
              M Offline
              MrPlankton
              wrote on last edited by
              #6

              It's been a while since I did any vb stuff but I suspect the problem is that you the return value needs to be an int and I believe you the add has a type argument as well that you need to specify. Dim returnValue As DbParameter (make int) returnValue = myCommand.CreateParameter returnValue.Direction = ParameterDirection.ReturnValue myCommand.Parameters.Add(returnValue) (add type to add, type would be SqlDbType.Int) here is an example in c# and this works. MyError = "adding ReturnValue parameter"; SqlC.Parameters.Add("@RETURN_VALUE", SqlDbType.Int); SqlC.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue; MyError = "building exec string for stored procedure"; string cmd = "DeleteDateRange"; SqlC.CommandType = CommandType.StoredProcedure; SqlC.CommandText = cmd; MyError = "Executing query, calling DeleteDateRange"; ReturnValue = SqlC.ExecuteNonQuery(); ReturnValue = Convert.ToInt32(SqlC.Parameters["@RETURN_VALUE"].Value); 2 cents, good luck.

              MrPlankton

              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