make sure that the max index on a list is less than the list size
-
hi, iv got this prgm where i choose a file, read the data in the file, compare it with a directory whether data in that file r in that directory.. data in the file 20090101 C1234 B0018 20090211 C1234 B0150 20090228 C5678 BRT10 20090228 C5678 BP001 when i debug the prgm, the error happen in convertCoop(coop) at Catch Ex As Exception.. b4 Catch part, the value of coop can be retrieve, but when i try to put values from table kodPortal to portal that is portal = ds.Tables(0).Rows(0).Item("portal"), at this part, no values are enter to portal. the error at catch is "make sure that the max index on a list is less than the list size". before this the prgm can run and come out with an output, but when i choose file that have no extension, the error come out.. after i did some editing, now any file that i choose have the same error. Pls help me... i have been posting this msg at several forum, but no one can help me..
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fdlg As OpenFileDialog = New OpenFileDialog() fdlg.Title = "C# Corner Open File Dialog" fdlg.InitialDirectory = "c:\\" fdlg.Filter = "All files (\*.\*)|\*.\*|All files (\*.\*)|\*.\*" fdlg.FilterIndex = 2 fdlg.RestoreDirectory = True If fdlg.ShowDialog() = Windows.Forms.DialogResult.OK Then TextBox1.Text = fdlg.FileName End If End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim folderopen As New FolderBrowserDialog With folderopen .RootFolder = Environment.SpecialFolder.Desktop .SelectedPath = "C:\\DOCUMENT" .Description = "Select the source directory" If .ShowDialog = Windows.Forms.DialogResult.OK Then ' Display the selected folder if the user clicked on the OK button. MessageBox.Show(.SelectedPath) TextBox2.Text = .SelectedPath End If End With End Sub
Private Sub convertCoop(ByVal coop As String)
Dim conn1 As New SqlClient.SqlConnection("Data Source=10.0.0.70;User ID= sysadm;Password=sysadm;Initial Catalog=SPGA\_Latihan;Persist Security Info=True;") Dim comm As SqlClient.SqlDataAdapter = Nothing Dim ds As DataSet = New DataSet() Dim strSQL2 As String = "SELECT folder, portal FROM kod
-
hi, iv got this prgm where i choose a file, read the data in the file, compare it with a directory whether data in that file r in that directory.. data in the file 20090101 C1234 B0018 20090211 C1234 B0150 20090228 C5678 BRT10 20090228 C5678 BP001 when i debug the prgm, the error happen in convertCoop(coop) at Catch Ex As Exception.. b4 Catch part, the value of coop can be retrieve, but when i try to put values from table kodPortal to portal that is portal = ds.Tables(0).Rows(0).Item("portal"), at this part, no values are enter to portal. the error at catch is "make sure that the max index on a list is less than the list size". before this the prgm can run and come out with an output, but when i choose file that have no extension, the error come out.. after i did some editing, now any file that i choose have the same error. Pls help me... i have been posting this msg at several forum, but no one can help me..
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fdlg As OpenFileDialog = New OpenFileDialog() fdlg.Title = "C# Corner Open File Dialog" fdlg.InitialDirectory = "c:\\" fdlg.Filter = "All files (\*.\*)|\*.\*|All files (\*.\*)|\*.\*" fdlg.FilterIndex = 2 fdlg.RestoreDirectory = True If fdlg.ShowDialog() = Windows.Forms.DialogResult.OK Then TextBox1.Text = fdlg.FileName End If End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim folderopen As New FolderBrowserDialog With folderopen .RootFolder = Environment.SpecialFolder.Desktop .SelectedPath = "C:\\DOCUMENT" .Description = "Select the source directory" If .ShowDialog = Windows.Forms.DialogResult.OK Then ' Display the selected folder if the user clicked on the OK button. MessageBox.Show(.SelectedPath) TextBox2.Text = .SelectedPath End If End With End Sub
Private Sub convertCoop(ByVal coop As String)
Dim conn1 As New SqlClient.SqlConnection("Data Source=10.0.0.70;User ID= sysadm;Password=sysadm;Initial Catalog=SPGA\_Latihan;Persist Security Info=True;") Dim comm As SqlClient.SqlDataAdapter = Nothing Dim ds As DataSet = New DataSet() Dim strSQL2 As String = "SELECT folder, portal FROM kod
I've answered you plenty of times. Your code sucks. Also, no-one is going to read this much code. Your core issues are: 1 - you read from a collection without checking first if it has objects at the index you specify 2 - this means your SQL is failing. #2 is the issue you need to resolve. #1 is just a matter of writing production quality code.
Christian Graus Driven to the arms of OSX by Vista.
-
I've answered you plenty of times. Your code sucks. Also, no-one is going to read this much code. Your core issues are: 1 - you read from a collection without checking first if it has objects at the index you specify 2 - this means your SQL is failing. #2 is the issue you need to resolve. #1 is just a matter of writing production quality code.
Christian Graus Driven to the arms of OSX by Vista.
i know my code sucks bcoz this is my 2nd time doing a prgm n b4 this i dont even know how to use vb or vb.net at all. it would be great if u give me any related article regarding issues 1 n 2. as i said b4 in my previous post (not this one but the same problem) my english r not that good, so whenever i try to google my problem, i cannot find any related article to my problem. i know u dont have time to entertain my stupid question, but if u can pls give the related link. im quite confused why it run ok n suddenly it cannot bcoz i didnt do any editing on ds.table part and it can retrieve data from table b4 this. tq