Dim con As New SqlConnection(Str) con.Open() Dim qstr, qstr1, qstr2 As String
qstr = "SELECT SUM(Amount) FROM PO_Items WHERE PONO='" + pnotxt.Text + "'"
qstr1 = "SELECT SUM(GST) FROM PO_Items WHERE PONO='" + pnotxt.Text + "'"
qstr2 = "SELECT SUM(GTotal) FROM PO_Items WHERE PONO='" + pnotxt.Text + "'"
Dim sqladp1 As New SqlDataAdapter(qstr, con)
Dim sqladp2 As New SqlDataAdapter(qstr1, con)
Dim sqladp3 As New SqlDataAdapter(qstr2, con)
Dim dta, dta1, dta2 As New DataSet
dta.Clear()
dta1.Clear()
dta2.Clear()
sqladp1.Fill(dta, "PO_Items")
sqladp2.Fill(dta1, "PO_Items")
sqladp3.Fill(dta2, "PO_Items")
subttl.Text = dta.Tables("PO_Items").Rows(0).Item(0)
gstttl.Text = dta1.Tables("PO_Items").Rows(0).Item(0)
gttl.Text = dta2.Tables("PO_Items").Rows(0).Item(0)
As far as I think,you could use Math.Round , ToString format or use
String.Format to convert the amount.
Just like as this:
Math.Round:
Math.Round(12252.80);
ToString format:
ToString("0.0");
String.Format:
String.Format("{0:0}", 12252.80);
Best regards,
Yijing Sun
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
299 Points
1172 Posts
Round off the amount in the text box
Jan 17, 2021 04:00 PM|Baiju EP|LINK
i have a amount in a text box
I am getting out put as
in some cases 12252.45
in some cases 12252.80
if its 12252.45 then i want amount as 12252
if its 12252.80 then i want amount as 12253
All-Star
53101 Points
23659 Posts
Re: Round off the amount in the text box
Jan 17, 2021 04:18 PM|mgebhard|LINK
Do you want to round the user's input or do you want to round the result if the TSQL SUM aggregate function?
I assume the SUM???
TSQL Reference
https://docs.microsoft.com/en-us/sql/t-sql/functions/round-transact-sql?view=sql-server-ver15
Also, as recommended in your other posts, you should use a parameter query not string concatenation.
Google
https://www.google.com/search?q=TSQL+parameter+query
All-Star
52683 Points
15721 Posts
Re: Round off the amount in the text box
Jan 17, 2021 09:21 PM|oned_gk|LINK
Suwandi - Non Graduate Programmer
Contributor
3730 Points
1431 Posts
Re: Round off the amount in the text box
Jan 18, 2021 02:24 AM|yij sun|LINK
Hi Baiju EP,
As far as I think,you could use Math.Round , ToString format or use String.Format to convert the amount.
Just like as this:
Math.Round:
ToString format:
String.Format:
Best regards,
Yijing Sun