Solved

Visual Studio Visual Basic -Sql Update Statment

Posted on 2007-03-28
1
218 Views
Last Modified: 2013-11-07
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
0
Comment
Question by:fsuedu
1 Comment
 
LVL 6

Accepted Solution

by:
kerryw60 earned 500 total points
ID: 18810738
Varchar should be able to handle it.   Try putting

.ToString()

on the field coming from your form. For example, if your field is

Activityadvdeposittxt.Text

Then try:

Activityadvdeposittxt.Text.ToString()

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now