you could use OLEDB, but that might be an overkill, I like JMC's sample
here the OLEDB sample, the CharacterSet 65001 is for Germany, you can Sort with ASC or DESC
somehow I could not Rate JMC's Post#2Code:Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click ProcessFileStates("E:\TestFolder\States.txt") End Sub Public Sub ProcessFileStates(ByVal filename As String) Dim file As New FileInfo(filename) Using con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""" & file.DirectoryName & """; Extended Properties='text;HDR=NO;FMT=Delimited(,);CharacterSet=65001';") 'CharacterSet 65001 is for German Umlaute ?", "?", "?", "?", "?", "? Using cmd As New OleDbCommand(String.Format("SELECT F1 As State,F2 as S FROM [{0}] ORDER BY F1 ASC;", file.Name), con) cmd.CommandType = CommandType.Text Using sda As New OleDbDataAdapter(cmd) Using ds As New DataSet() sda.Fill(ds) 'DataGridView1.DataSource = ds.Tables(0) With ComboBox1 .DisplayMember = "State" .ValueMember = "S" .DataSource = ds.Tables(0) End With End Using End Using End Using End Using End Sub Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Label1.Text = ComboBox1.SelectedValue End Sub
also the German Umlaute show as ?




Reply With Quote