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. General Programming
  3. Visual Basic
  4. Strange variable convertion...

Strange variable convertion...

Scheduled Pinned Locked Moved Visual Basic
helpdatabasesql-serversysadminquestion
5 Posts 3 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.
  • C Offline
    C Offline
    CJotaO
    wrote on last edited by
    #1

    Hi! Please take a look at this code... Public Sub GravaConfiguracao_Fideliza(ByVal intESC As Integer, ByVal dblVE As intPE As Integer) Dim strInsert As String = "Insert Into Configuracao (Escalao, ValorEscalao, PontosEscalao) Values (" & intESC & ", " & dblVE & ", " & intPE & ")" Please note the variable dblVE. It is a Double variable. If it's value is for instance 0.5 when the strInsert string is created the dblVE variable is converted to 0,5 and then SQL Server reports an error because in the end the string is created with 3 fields and "4" values... Can anyone help me with this? TIA Jorge

    G G 2 Replies Last reply
    0
    • C CJotaO

      Hi! Please take a look at this code... Public Sub GravaConfiguracao_Fideliza(ByVal intESC As Integer, ByVal dblVE As intPE As Integer) Dim strInsert As String = "Insert Into Configuracao (Escalao, ValorEscalao, PontosEscalao) Values (" & intESC & ", " & dblVE & ", " & intPE & ")" Please note the variable dblVE. It is a Double variable. If it's value is for instance 0.5 when the strInsert string is created the dblVE variable is converted to 0,5 and then SQL Server reports an error because in the end the string is created with 3 fields and "4" values... Can anyone help me with this? TIA Jorge

      G Offline
      G Offline
      Guerven
      wrote on last edited by
      #2

      ei, Public Sub GravaConfiguracao_Fideliza(ByVal intESC As Integer, ByVal dblVE As intPE As Integer) can you tell what this parameter declaration mean. if confused about the double AS is that a valid statement?

      GUERVEN Xuriuxs

      C 1 Reply Last reply
      0
      • G Guerven

        ei, Public Sub GravaConfiguracao_Fideliza(ByVal intESC As Integer, ByVal dblVE As intPE As Integer) can you tell what this parameter declaration mean. if confused about the double AS is that a valid statement?

        GUERVEN Xuriuxs

        C Offline
        C Offline
        CJotaO
        wrote on last edited by
        #3

        Hi! I'm sorry about the mistaken code... The correct one is as follows: Public Sub GravaConfiguracao_Fideliza(ByVal intESC As Integer, ByVal dblVE As Double, ByVal intPE As Integer) Dim strInsert As String = "Insert Into Configuracao (Escalao, ValorEscalao, PontosEscalao) Values (" & intESC & ", " & dblVE & ", " & intPE & ")" Thnaks Jorge

        1 Reply Last reply
        0
        • C CJotaO

          Hi! Please take a look at this code... Public Sub GravaConfiguracao_Fideliza(ByVal intESC As Integer, ByVal dblVE As intPE As Integer) Dim strInsert As String = "Insert Into Configuracao (Escalao, ValorEscalao, PontosEscalao) Values (" & intESC & ", " & dblVE & ", " & intPE & ")" Please note the variable dblVE. It is a Double variable. If it's value is for instance 0.5 when the strInsert string is created the dblVE variable is converted to 0,5 and then SQL Server reports an error because in the end the string is created with 3 fields and "4" values... Can anyone help me with this? TIA Jorge

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

          Use the ToString method to convert the value instead of using implicit conversion. Then you can specify a culture or format provider. Use CultureInfo.InvariantCulture or NumberFormatInfo.InvariantInfo to get a format that uses decimal period.

          --- b { font-weight: normal; }

          C 1 Reply Last reply
          0
          • G Guffa

            Use the ToString method to convert the value instead of using implicit conversion. Then you can specify a culture or format provider. Use CultureInfo.InvariantCulture or NumberFormatInfo.InvariantInfo to get a format that uses decimal period.

            --- b { font-weight: normal; }

            C Offline
            C Offline
            CJotaO
            wrote on last edited by
            #5

            Hi! I solved the problem thanks to you. Thank you very much for the tip! Jorge

            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