0
   Dim DMC_No As New List(Of Integer)
                cmd.CommandText = "SELECT MC_No FROM tbl_MainComp WHERE EquipTag=  '" & TextBox1.Text & "'"
                Using reader As OleDb.OleDbDataReader = cmd.ExecuteReader()
                    While reader.Read()
                        DMC_No.Add(reader.GetInt32(reader.GetOrdinal("MC_No")))
                    End While
                End Using



                Dim DFM_No As New List(Of Integer)

                For i = 0 To DMC_No.Count - 1
                    MessageBox.Show(DMC_No.Item(i)) 'This line to to test is there any value in array list and it get the correct value
                    cmd.CommandText = "SELECT FM_No FROM tbl_FailureMode WHERE MC_No=  " & DMC_No.Item(i) & ""
                    Using reader2 As OleDb.OleDbDataReader = cmd.ExecuteReader()
                        While reader2.Read()
                            DFM_No.Add(reader2.GetInt32(reader2.GetOrdinal("FM_No")))
                        End While
                    End Using
                    MessageBox.Show(DMC_No.Item(i))'This line to to test is there any value in array list and it get the correct value
                Next i

I think my problem is occuring at this line

cmd.CommandText = "SELECT FM_No FROM tbl_FailureMode WHERE MC_No=  " & DMC_No.Item(i) & ""

When i set the DMC_No.Item(i) value as hard code it able to run smoothly, but when i add the DMC_No.Item(i) and i check the value by using

  Dim sResult As String = String.Join(", ", DFM_No.ToArray())
                Dim str As String
                str = String.Join(",", DFM_No)

                MessageBox.Show(str)

It does not return any value

3
Contributors
2
Replies
15
Views
1 Year
Discussion Span
Last Post by Reverend Jim
0

Put a breakpoint at

cmd.CommandText = "SELECT FM_No FROM tbl_FailureMode WHERE MC_No=  " & DMC_No.Item(i) & ""

and check the value of DMC_No.Item(i) in either the watch or immediate windows. Note that you don't need the "" at the end. You can just use

cmd.CommandText = "SELECT FM_No FROM tbl_FailureMode WHERE MC_No=  " & DMC_No.Item(i)

or even

cmd.CommandText = "SELECT FM_No FROM tbl_FailureMode WHERE MC_No=  " & DMC_No(i)

Edited by Reverend Jim

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.