October 20, 2015 at 5:11 am
Hello People,
I have made following code.
my problem is the loop stops if the table doesn't exists,
Private Sub GetOrderNR()
Dim CompanyID(5) As String
CompanyID = Company.SelectedItem.ToString().Split("-")
SQL.ExecQuery(String.Format("SELECT ordernr as 'myOrdernr' FROM [myDB].Main.myOrders as tt where Companynr={0}", CompanyID(1).Trim()))
' CLEAR COMBOBOX
OrderNR.Items.Clear()
' MsgBox(SQL.Exception)
If SQL.RecordCount > 0 Then
For Each r As DataRow In SQL.SQLDS.Tables(0).Rows
OrderNR.Items.Add(r(0))
Next
'SET THE COMBOBOX TO THE FIRST RECORD
OrderNR.SelectedIndex = 0
ElseIf SQL.Exception <> "" Then
'REPORT ERRORS
MsgBox(SQL.Exception)
End If
End Sub
I want the loop to continue instead either alert an msgbox
Could someone help me?
Thank you in advance
October 20, 2015 at 5:39 am
Your posting in the wrong forum i think , this is pure Vb.Net
https://msdn.microsoft.com/en-us/library/ms228598%28v=vs.90%29.aspx
the above link should work in creating a loop , you simply need to remove the message block from you code,
try VB.net forum or C# forum instead
October 20, 2015 at 5:48 am
you are correct sorry.
October 20, 2015 at 5:48 am
this is solved
If SQL.RecordCount > 0 Then
If SQL.SQLDS.Tables.Count > 0 Then
For Each r As DataRow In SQL.SQLDS.Tables(0).Rows
OrderNR.Items.Add(r(0))
Next
OrderNR.SelectedIndex = 0
End If
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply