简体   繁体   中英

VB.NET decimal value from Datagridview update into SQL table - formatting error

I've got a problem when trying to update an sql record, taking the value from DataGridView after the user alter the cell value. Inside the table the value to be modified is a decimal(18,8) , when I try to insert a value such as 50.55 inside the DataGridView , then is updated inside the Sql table as 5055.00.

How should I proceed?

Try setting the ValueType for the row and you should be good to go! For example, in your SQL table, the column decimal(18,8) is a number that has 10 digits before the decimal and 8 digits after the decimal thus you need to format your DGV columns as follows (as an example):

DataGridView1.Columns.Item(3).DefaultCellStyle.Format = "N8"  

DataGridView1.Columns.Item(3).ValueType = GetType(Decimal)

For more info read this article

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM