This is a migrated thread and some comments may be shown as answers.

How Can I Deal with float number in SQL

2 Answers 83 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mohammed
Top achievements
Rank 1
Mohammed asked on 14 Apr 2011, 04:01 PM
Dear Friends,
could you please help me to get the way to read a percent value (0, 0.1,... to 1) in a textbox using % value like 0%, 1% to 100%
my database has a column with name of percentcomp as float but i field to read it through my application that i convert the value to string to be appeared in my text box but unlikely when i convert to string I lose the value. kindly find my code below


 Protected Sub DivID_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles DivID.Load
        If Not Page.IsPostBack Then


            If Not (DivID.Text = "") Then
                ' Create a Select statement that searches for a record
                ' matching the specific Call Number from the Value property.
                Dim selectSQL As String
                selectSQL = " SELECT MasterEntry.EquiryType, DivisionsInv.ID, DivisionsInv.LogNumber ,  DivisionsInv.SolutionComp, DivisionsInv.Division, DivisionsInv.ProposedValue, DivisionsInv.Employee, DivisionsInv.Status, DivisionsInv.PercentCompl, DivisionsInv.ClosedDate, DivisionsInv.HrsWorked, DivisionsInv.Remarks, Employees.Name, Employees.EmpNumber"
                selectSQL &= " FROM MasterEntry INNER JOIN DivisionsInv ON MasterEntry.LogNumber = DivisionsInv.LogNumber INNER JOIN Employees ON DivisionsInv.Employee = Employees.EmpNumber "
                selectSQL &= "WHERE DivisionsInv.ID='" & DivID.Text & "' "
                selectSQL &= " AND EmpNumber = '" & Profile.EmpNum & "'"


                ' Define the ADO.NET objects.
                Dim strConnString As String = ConfigurationManager.ConnectionStrings("TSDATA2ConnectionString").ConnectionString()
                Dim con As New SqlConnection(strConnString)

                Dim cmd As New SqlCommand(selectSQL, con)
                Dim reader As SqlDataReader
                ' Try to open database and read information.

                Try
                    con.Open()
                    reader = cmd.ExecuteReader()
                    reader.Read()
                    UpdateButton.Enabled = True
                    Panel1.Visible = True
                    ' Fill the controls.
                    ' If reader("AccManager").ToString() <> orgn.SelectedValue Then
                    'UpdateTXT0.Text = "Sorry your are not Authorized"
                    'End If

                    EngineerName.Text = reader("Name").ToString()

                    Eng_LogNumber.Text = reader("LogNumber").ToString
                    SolutionText.Text = reader("SolutionComp").ToString()
                    DivisionText.Text = reader("Division").ToString()
                    ProposedValueText.Text = reader("ProposedValue").ToString()
                    StatusText.SelectedValue = reader("Status").ToString()
                    PercentCompl.Text = reader("PercentCompl").ToString()
                    If Not (reader("ClosedDate").ToString() = "") Then
                        ClosedDate.SelectedDate = reader("ClosedDate").ToString()
                    End If
                    HrsWorked.Text = reader("HrsWorked").ToString()

                    remark.Text = reader("Remarks").ToString()

                    TypeText.Text = reader("EquiryType").ToString()

                Catch err As Exception
                    Labelerr.Text = "This Call may not assigned to you or an Error present "
                    UpdateButton.Enabled = False
                    Panel1.Visible = False






                Finally
                    con.Close()
                End Try
            End If
        End If
    End Sub


Best Regards,

2 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 14 Apr 2011, 04:48 PM
Hello Mohammed,

Instead of converting the float value manually, consider using our RadNumericTextBox control in percent mode to do that automatically for you. You can test it on this demo to see whether the control fits your scenario.
 
Best regards,
Sebastian
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Mohammed
Top achievements
Rank 1
answered on 14 Apr 2011, 10:47 PM
thanks a lot it solve my issue
Tags
General Discussions
Asked by
Mohammed
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Mohammed
Top achievements
Rank 1
Share this question
or