Link to home
Start Free TrialLog in
Avatar of fsuedu
fsuedu

asked on

Visual Studio Visual Basic -Sql Update Statment

Trying to update some fields to a sql database 2005 in sub FormClosing of datatype numeric(10, 2)
with the code below:

Try
            objConn.Open()
            With colCmd
                .CommandType = CommandType.Text
                .CommandText = "Update Settlement Set PreviouAdvDepositstxt = '" & PreviouAdvDepositstxtTextBox.Text & "', TransferGuestLedgertxt = '" & TransferGuestLedgertxt.Text & "', ActivityAdvdeposittxt = '" & Activityadvdeposittxt.Text & "'Where Sitetxt = 2 and PrimaryKey = (Select Max(PrimaryKey) from Settlement where SiteTxt=2)"
                .Connection = objConn
                .ExecuteNonQuery()
            End With
            objConn.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

Im getting a error message of: Error converting data type varchar to numeric.
It happens when the number is more then 4 spaces past the Decimal because the number has a comma in it for example 1,000.00- I need the comma to display, but also need to import it into the sql database.

Any ideas
ASKER CERTIFIED SOLUTION
Avatar of kerryw60
kerryw60

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial