Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Visual Studio Visual Basic -Sql Update Statment

Posted on 2007-03-28
1
Medium Priority
?
225 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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…
Suggested Courses

704 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