Results 1 to 9 of 9

Thread: Problem When VB save in DB

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Problem When VB save in DB

    Hi to all:

    This peace of code put one value in DB:

    Code:
     Dim con1 As New OleDb.OleDbConnection(String.Format("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = " & drive & IDempresa))
            Dim sSQL As String
    
            valorcolocardebito = FormatNumber(valorcolocardebito, 2)
    
            If valorcolocardebito = 0 Then
                valorcolocardebito = 0
            End If
    
    
            sSQL = "UPDATE balancetegeral SET numeroconta = @contaacolocar, "
            sSQL = sSQL & "mensaisdebito = @valorcolocardebito "
            sSQL = sSQL & "WHERE numeroconta = @contaacolocar"
    
            Dim command As New OleDb.OleDbCommand(sSQL, con1)
    
            With command.Parameters
                .AddWithValue("@contaacolocar", contaacolocar)
    
                If valorcolocardebito = 0 Then
                    .AddWithValue("@mensaisdebito", DBNull.Value)
                Else
                    .AddWithValue("@mensaisdebito", valorcolocardebito)
                End If
            End With
    
            con1.Open()
            command.ExecuteNonQuery()
            con1.Close()
    I had run the code step by step and he do a strange,better, very strange thing...
    The value puted in valorcolocardebito = 263.733,69 and when I confirm this value in DB i have 263.733,70...
    More surprise is because he make this for an values and for other save very well...
    This could be surealistic,but it is that I have and sincerely i don't know way this happen...

    Can anyone give me an suggestion?

    Thanks
    Last edited by sacramento; Nov 19th, 2009 at 08:32 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width