none
how to insert decimal values into database? RRS feed

  • Question

  • Hi all

    I Have a function in my codes ...

     Function Calc_Point() As System.Decimal
            '   /////
            '   //////
            '   ///////
            '   ////////
            Return 2.45
    
        End Function

    my value is 2.45 

    please see my tsql Codes...

    Dim Tsql As string =String.Format("
                UPDATE [dps].[Performance]
                SET [UserRef]={0},[Status]={1},[EndDate]='{2}',[Point]={3}
                WHERE [PerformanceId]={4}", UserRef, cboStatus.SelectedValue ,Calender.GetDateAndTimeFromServer,    Calc_Point, DataGridViewX1.CurrentRow.Cells(0).Value.ToString)
    

    but i see this codes ...

    UPDATE [dbo].[Performance] SET [UserRef]=1,[Status]=2,[EndDate]='2018/06/02' ,[Point]=2/45 WHERE [PerformanceId]=1
    

    when run codes i see 0 in point fields ...

    my datatype is decimal

    Point	decimal(5, 2)	Unchecked

    how to solve it?


    Name of Allah, Most Gracious, Most Merciful and He created the human

    Friday, August 24, 2018 6:51 PM

Answers

  • Have you tried writing the UPDATE in SSMS (SQL-Server Management Studio) and use parameters?

    Please use parameters when sending information to your table in your VB.NET code.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by sh 2020 Saturday, August 25, 2018 5:33 PM
    Friday, August 24, 2018 8:34 PM
    Moderator

All replies

  • Have you tried writing the UPDATE in SSMS (SQL-Server Management Studio) and use parameters?

    Please use parameters when sending information to your table in your VB.NET code.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by sh 2020 Saturday, August 25, 2018 5:33 PM
    Friday, August 24, 2018 8:34 PM
    Moderator
  • thanks dear

    i used parameter and solved it.

    ;-)


    Name of Allah, Most Gracious, Most Merciful and He created the human

    Saturday, August 25, 2018 5:33 PM