Solved

Visual Studio Visual Basic -Sql Update Statment

Posted on 2007-03-28
1
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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 and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

631 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