Results 1 to 2 of 2

Thread: [RESOLVED] Data Formatting

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Posts
    362

    Resolved [RESOLVED] Data Formatting

    I am passing the following code:


    Code:
    Try
                    Using connection As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=D:\ProjectMW\MachineWale\MachineWale\DatabaseMW.mdf;Integrated Security=True;User Instance=True")
                        connection.Open()
                        Using command As New SqlCommand("SELECT * FROM SubPack order by SlNo", connection) '
                            Using reader As SqlDataReader = command.ExecuteReader()
                                While reader.Read()
                                    ComboBox1.Items.Add(reader("SlNo") + "-" + reader("Type".ToString) + "-" + reader("Duration".ToString) + "M" + "-" + reader("Machine".ToString))
                                End While
                            End Using
                        End Using
                    End Using
                Catch ex As Exception
                    MsgBox(ex.ToString, MsgBoxStyle.Exclamation)
                End Try
    And i am getting following result:

    1 -WL -3M -2
    When i need result as:

    1-WL-3M-2
    I tried TRIM but to no use. Any idea on how to do it?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Data Formatting

    vb Code:
    1. reader("fieldName").tostring.trim + "-" + reader("otherfieldName").tostring.trim

    should do it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width