Help with for loop

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Help with for loop

Post by CesarePlay »

I need help trying to stop the following loop from been read twice:

Code: Select all

For counter = 0 To (ImpArray.Length - 1)
                If IsNumeric(ImpArray(counter)) Then

                    'GET NUMBER OF RISKS
                    Dim strSQL1 = "SELECT _SAFETY_Risks.*, _EMS_Reg_Impacts.IMPACT AS HAZARDDESC " & _
                            "FROM _SAFETY_Risks INNER JOIN " & _
                            "_EMS_Reg_Impacts ON _SAFETY_Risks.HAZARD = _EMS_Reg_Impacts.ID " & _
                            "WHERE     (_SAFETY_Risks.REC_COUNT = 0) AND (_EMS_Reg_Impacts.REC_COUNT = 0)  AND ASPECTID = '" & lstItems.SelectedItem.Value & "' AND _EMS_Reg_Impacts.ID = '" & ImpArray(counter) & "'"

                    Dim dsNumRisks As New DataSet
                    dsNumRisks = currCC.executeQuery(Application("ConnString"), strSQL1, "PPE")

                    'Create Data Row
                    Dim rNumRisks As DataRow

                    For Each rNumRisks In dsNumRisks.Tables("PPE").Rows
                        txtNumRisks.Text = CInt(txtNumRisks.Text) + 1
                    Next

                    If txtNumImpacts.Text = "" Then
                        txtNumImpacts.Text = "1"
                    Else
                        txtNumImpacts.Text = CInt(txtNumImpacts.Text) + 1
                    End If
                End If
            Next

            lstHazards.Items.Clear()

            Dim initItem As New System.Web.UI.WebControls.ListItem
            initItem.Value = "0"
            initItem.Text = "-- Not Selected --"
            lstHazards.Items.Add(initItem)

            For counter = 0 To (ImpArray.Length - 1)

                'Response.Write(ImpArray(counter) & "<br>")

                If IsNumeric(ImpArray(counter)) Then

                    '==============Get Impact Name==================
                    strSQL = "SELECT * FROM _EMS_Reg_Impacts WHERE ID = '" & ImpArray(counter) & "'"

                    Dim dsImpName As New DataSet
                    dsImpName = currCC.executeQuery(Application("ConnString"), strSQL, "ImpName")

                    Dim rImpName As DataRow

                    If dsImpName.Tables("ImpName").Rows.Count > 0 Then
                        rImpName = dsImpName.Tables("ImpName").Rows(0)

                        '============HAZARDS DROP-DOWN=============
                        Dim currItem As New System.Web.UI.WebControls.ListItem
                        currItem.Value = ImpArray(counter)
                        currItem.Text = rImpName("IMPACT")
                        lstHazards.Items.Add(currItem)

                        '=========================================
                    End If

                    'GET RISKS
                    Dim strSQL1 = "SELECT _SAFETY_Risks.*, _EMS_Reg_Impacts.IMPACT AS HAZARDDESC " & _
                            "FROM _SAFETY_Risks INNER JOIN " & _
                            "_EMS_Reg_Impacts ON _SAFETY_Risks.HAZARD = _EMS_Reg_Impacts.ID " & _
                            "WHERE (_SAFETY_Risks.REC_COUNT = 0) AND (_EMS_Reg_Impacts.REC_COUNT = 0) AND ASPECTID = '" & lstItems.SelectedItem.Value & "'"

                    Dim ds2 As New DataSet
                    ds2 = currCC.executeQuery(Application("ConnString"), strSQL1, "PPE")

                    'Create Data Row
                    Dim r2 As DataRow

                    For Each r2 In ds2.Tables("PPE").Rows

                        Dim cell1 As New System.Web.UI.WebControls.TableCell
                        Dim cell2 As New System.Web.UI.WebControls.TableCell
                        Dim cellremove As New System.Web.UI.WebControls.TableCell
                        Dim tr As New System.Web.UI.WebControls.TableRow

                        cell1.Text = currCC.retrieveString("RISK", r2)
                        cell2.Text = currCC.retrieveString("HAZARDDESC", r2)

                        cell1.CssClass = "content3"
                        cell2.CssClass = "content3"
                        cellremove.CssClass = "content3"

                        tr.Cells.Add(cell1)
                        tr.Cells.Add(cell2)

                        Dim cmdRemove As New System.Web.UI.HtmlControls.HtmlButton
                        cmdRemove.Attributes.Add("onclick", "removerisks('" & r2("ID") & "')")
                        cmdRemove.InnerText = "Remove"
                        cmdRemove.Style.Add("font-size", "10px")

                        cellremove.Controls.Add(cmdRemove)

                        tr.Cells.Add(cellremove)

                        tblRisks.Rows.Add(tr)

                        makeImpactRow(ImpArray(counter), RiskCounter, r2)

                        RiskCounter += 1

                    Next

                End If

            Next
I tried redoing this whole loop but separating it leads to more errors. The problem with this loop is when the page refreshes after changing an item in a list box the risks function runs through this loop twice and so duplicates the risks in so you end up with 2 copies of the same risk. I have fixed many errors on this page but this error has me stumped as to how it should be fixed.
Image
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Help with for loop

Post by CesarePlay »

Does anyone have any ideas how to make this code work correctly? It works fine until I change a list box and then the function just duplicates the one field. :x
Image
User avatar
Ron2K
Forum Technical Administrator
Posts: 9050
Joined: 04 Jul 2006, 16:45
Location: Upper Hutt, New Zealand
Contact:

Re: Help with for loop

Post by Ron2K »

If you only want the loop to be iterated once only, then it's simple - don't have a loop! Unless you mean that your entire function is getting called twice when it should be called once - either way, you have a logic error, and you need to fix it.

I'm not going to correct your code, because a) I don't speak VB, b) I believe that VB was made by Satan himself (refer to point a), and c) you'll only become a better coder if you learn how to debug your code yourself. Suffice to say, I assume that you're using Visual Studio - it has some useful debuggering features. Try putting some breakpoints in at key parts of the code, step through your code, keep track of what's being contained in your variables. You want to get to the point where you can say "at line X, I was expecting to see Y, but Z happened instead" - then the rest is easy.
Kia kaha, Kia māia, Kia manawanui.
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Help with for loop

Post by RuadRauFlessa »

Ron2K wrote:If you only want the loop to be iterated once only, then it's simple - don't have a loop! Unless you mean that your entire function is getting called twice when it should be called once - either way, you have a logic error, and you need to fix it.

I'm not going to correct your code, because a) I don't speak VB, b) I believe that VB was made by Satan himself (refer to point a), and c) you'll only become a better coder if you learn how to debug your code yourself. Suffice to say, I assume that you're using Visual Studio - it has some useful debuggering features. Try putting some breakpoints in at key parts of the code, step through your code, keep track of what's being contained in your variables. You want to get to the point where you can say "at line X, I was expecting to see Y, but Z happened instead" - then the rest is easy.
I'm with Ron2K on this one. :D
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Help with for loop

Post by CesarePlay »

Ron2K wrote:If you only want the loop to be iterated once only, then it's simple - don't have a loop! Unless you mean that your entire function is getting called twice when it should be called once - either way, you have a logic error, and you need to fix it.

I'm not going to correct your code, because a) I don't speak VB, b) I believe that VB was made by Satan himself (refer to point a), and c) you'll only become a better coder if you learn how to debug your code yourself. Suffice to say, I assume that you're using Visual Studio - it has some useful debuggering features. Try putting some breakpoints in at key parts of the code, step through your code, keep track of what's being contained in your variables. You want to get to the point where you can say "at line X, I was expecting to see Y, but Z happened instead" - then the rest is easy.
I thought it was that but I been through all the code and can't find why it is doing that. I did a write response piece by this code and using debug break at it as well. I been trying the list box code to find out why it affects this piece only because the other two functions work correctly.

I was thinking to solve it I might have to rewrite the entire function. Whoever made this code did not check that it worked. Earlier I fixed javascript errors, sql errors and syntax errors.

But overall this whole application should be rewritten. It is too full of mistakes.

I try again to see what other functions interact with this one and take it from there.
Image
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Help with for loop

Post by CesarePlay »

RuadRauFlessa wrote:
Ron2K wrote:If you only want the loop to be iterated once only, then it's simple - don't have a loop! Unless you mean that your entire function is getting called twice when it should be called once - either way, you have a logic error, and you need to fix it.

I'm not going to correct your code, because a) I don't speak VB, b) I believe that VB was made by Satan himself (refer to point a), and c) you'll only become a better coder if you learn how to debug your code yourself. Suffice to say, I assume that you're using Visual Studio - it has some useful debuggering features. Try putting some breakpoints in at key parts of the code, step through your code, keep track of what's being contained in your variables. You want to get to the point where you can say "at line X, I was expecting to see Y, but Z happened instead" - then the rest is easy.
I'm with Ron2K on this one. :D
If I wrote this code I would not have used a loop either. This application has been upgraded from about 1998 and been fixed ever since. I am now trying to get it to work correctly.
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Help with for loop

Post by RuadRauFlessa »

Ok to start off with I can see 4 loops there. Which one is it that executes twice and should not?
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Help with for loop

Post by CesarePlay »

RuadRauFlessa wrote:Ok to start off with I can see 4 loops there. Which one is it that executes twice and should not?
It seems to be the top one that is going through it twice. I tried moving the next to closer to the top but then the sqlSQL1 does not work.

I compared this function to the two that were working and it is totally different. If at all possible I need to get it out of this for loop at the top and still get it to work.
Image
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Help with for loop

Post by CesarePlay »

I checked it again and it seems to be the third for loop in this function. When you choose the first item the loop works but if you select the second one it goes through it twice but the third option does not work properly at all. :? :? :?
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Help with for loop

Post by RuadRauFlessa »

Ok
So where does ImpArray come from and how many values is in it?

Dim dsNumRisks As New DataSet is a waste of memory so do Dim dsNumRisks As DataSet

Any reason why txtNumRisks.Text is text and not an int :?:

Also this loop only counts the amount of entries returned by the query. It is much better to adjust the query and only have it return a count than doing all of this. Much faster too.

I would also try and figure a way of doing all of that stuff in the loop just below it as it iterates for the same list (ImpArray).
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Help with for loop

Post by RuadRauFlessa »

CesarePlay wrote:I checked it again and it seems to be the third for loop in this function. When you choose the first item the loop works but if you select the second one it goes through it twice but the third option does not work properly at all. :? :? :?
You mean

Code: Select all

For Each r2 In ds2.Tables("PPE").Rows

  Dim cell1 As New System.Web.UI.WebControls.TableCell
  Dim cell2 As New System.Web.UI.WebControls.TableCell
  Dim cellremove As New System.Web.UI.WebControls.TableCell
  Dim tr As New System.Web.UI.WebControls.TableRow

  cell1.Text = currCC.retrieveString("RISK", r2)
  cell2.Text = currCC.retrieveString("HAZARDDESC", r2)

  cell1.CssClass = "content3"
  cell2.CssClass = "content3"
  cellremove.CssClass = "content3"

  tr.Cells.Add(cell1)
  tr.Cells.Add(cell2)

  Dim cmdRemove As New System.Web.UI.HtmlControls.HtmlButton
  cmdRemove.Attributes.Add("onclick", "removerisks('" & r2("ID") & "')")
  cmdRemove.InnerText = "Remove"
  cmdRemove.Style.Add("font-size", "10px")

  cellremove.Controls.Add(cmdRemove)

  tr.Cells.Add(cellremove)

  tblRisks.Rows.Add(tr)

  makeImpactRow(ImpArray(counter), RiskCounter, r2)

  RiskCounter += 1

Next
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Help with for loop

Post by CesarePlay »

RuadRauFlessa wrote:Ok
So where does ImpArray come from and how many values is in it?

Dim dsNumRisks As New DataSet is a waste of memory so do Dim dsNumRisks As DataSet

Any reason why txtNumRisks.Text is text and not an int :?:

Also this loop only counts the amount of entries returned by the query. It is much better to adjust the query and only have it return a count than doing all of this. Much faster too.

I would also try and figure a way of doing all of that stuff in the loop just below it as it iterates for the same list (ImpArray).


ImpArray as far as I can gather is the name of the array used and at the moment it has 4 values in it. Ideally it works by counting the number of values in the array.

Here is where it is called:

Code: Select all

  

im ImpArray As Array
ImpArray = ImpactsArray("IMPACTS", r)

txtNumRisks gets converted to int in one function. This I know because I just tracked it.

I agree with your assessment. I am not actually sure who wrote the function though and been trying the last week to get the whole page working. If you think this part is bad you should see the rest of the page. :x

One guy where I work thinks that this function is been called twice but we can't find out where. The whole code is a mess.
Image
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Help with for loop

Post by CesarePlay »

This one is the loop that has this duplicate problem from the response.write code we put in:

Code: Select all

            For counter = 0 To (ImpArray.Length - 1)

                If IsNumeric(ImpArray(counter)) Then

                    '==============Get Impact Name==================
                    strSQL = "SELECT * FROM _EMS_Reg_Impacts WHERE ID = '" & ImpArray(counter) & "'"

                    Dim dsImpName As New DataSet
                    dsImpName = currCC.executeQuery(Application("ConnString"), strSQL, "ImpName")

                    Dim rImpName As DataRow

                    If dsImpName.Tables("ImpName").Rows.Count > 0 Then
                        rImpName = dsImpName.Tables("ImpName").Rows(0)

                        '============HAZARDS DROP-DOWN=============
                        Dim currItem As New System.Web.UI.WebControls.ListItem
                        currItem.Value = ImpArray(counter)
                        currItem.Text = rImpName("IMPACT")
                        lstHazards.Items.Add(currItem)

                        '=========================================
                    End If

                    'GET RISKS
                    Dim strSQL1 = "SELECT _SAFETY_Risks.*, _EMS_Reg_Impacts.IMPACT AS HAZARDDESC " & _
                            "FROM _SAFETY_Risks INNER JOIN " & _
                            "_EMS_Reg_Impacts ON _SAFETY_Risks.HAZARD = _EMS_Reg_Impacts.ID " & _
                            "WHERE (_SAFETY_Risks.REC_COUNT = 0) AND (_EMS_Reg_Impacts.REC_COUNT = 0) AND ASPECTID = '" & lstItems.SelectedItem.Value & "'"

                    'Response.Write(strSQL1 & "<br>")

                    Dim ds2 As New DataSet
                    ds2 = currCC.executeQuery(Application("ConnString"), strSQL1, "PPE")

                    'Create Data Row
                    Dim r2 As DataRow

                    For Each r2 In ds2.Tables("PPE").Rows

                        Dim cell1 As New System.Web.UI.WebControls.TableCell
                        Dim cell2 As New System.Web.UI.WebControls.TableCell
                        Dim cellremove As New System.Web.UI.WebControls.TableCell
                        Dim tr As New System.Web.UI.WebControls.TableRow

                        cell1.Text = currCC.retrieveString("RISK", r2)
                        cell2.Text = currCC.retrieveString("HAZARDDESC", r2)

                        cell1.CssClass = "content3"
                        cell2.CssClass = "content3"
                        cellremove.CssClass = "content3"

                        tr.Cells.Add(cell1)
                        tr.Cells.Add(cell2)

                        Dim cmdRemove As New System.Web.UI.HtmlControls.HtmlButton
                        cmdRemove.Attributes.Add("onclick", "removerisks('" & r2("ID") & "')")
                        cmdRemove.InnerText = "Remove"
                        cmdRemove.Style.Add("font-size", "10px")

                        cellremove.Controls.Add(cmdRemove)

                        tr.Cells.Add(cellremove)

                        tblRisks.Rows.Add(tr)

                        'makeImpactRow(RiskCounter, r2)
                        makeImpactRow(ImpArray(counter), RiskCounter, r2)

                        RiskCounter += 1

                    Next

                End If

            Next
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Help with for loop

Post by RuadRauFlessa »

So it actually runs trough that code 8 times. (4 values in array x 2).

That said you are propably getting double entries in the list box on the page too :?:
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Help with for loop

Post by CesarePlay »

RuadRauFlessa wrote:So it actually runs trough that code 8 times. (4 values in array x 2).

That said you are propably getting double entries in the list box on the page too :?:
No I was getting double values in the table it populates. When I use the response.write in that piece it gets written twice and the table gets duplicate rows with the same data. Earlier today it duplicated the same code 8 times with the results I had 8 x water hazard. Now however it only duplicates the data in the table.

The table the data goes in is tblRisks It is a dynamic table that only appears once data is added to it.
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Help with for loop

Post by RuadRauFlessa »

How many rows does

Code: Select all

'GET RISKS
                    Dim strSQL1 = "SELECT _SAFETY_Risks.*, _EMS_Reg_Impacts.IMPACT AS HAZARDDESC " & _
                            "FROM _SAFETY_Risks INNER JOIN " & _
                            "_EMS_Reg_Impacts ON _SAFETY_Risks.HAZARD = _EMS_Reg_Impacts.ID " & _
                            "WHERE (_SAFETY_Risks.REC_COUNT = 0) AND (_EMS_Reg_Impacts.REC_COUNT = 0) AND ASPECTID = '" & lstItems.SelectedItem.Value & "'"

                    Dim ds2 As New DataSet
                    ds2 = currCC.executeQuery(Application("ConnString"), strSQL1, "PPE")
return
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Help with for loop

Post by CesarePlay »

It returns depending on the option chosen anything from 1 to as many as 8 rows
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Help with for loop

Post by RuadRauFlessa »

So in your db you would have
ID VAL
1 a
1 b
1 c
2 d
3 e
3 f
3 g
3 h
4 i
5 j

So say the ImpArray has two elements 1 and 3 it should go through the main loop 2 and 7 times through the inner one with the dataset giving you:

1 a
1 b
1 c
3 e
3 f
3 g
3 h

But at the moment you are getting

1 a
1 a
1 a
1 a
1 b
1 b
1 b
1 b
1 c
1 c
1 c
1 c
3 e
3 e
3 e
3 e
3 f
3 f
3 f
3 f
3 g
3 g
3 g
3 g
3 h
3 h
3 h
3 h

or

1 a
1 b
1 c
3 e
3 f
3 g
3 h
1 a
1 b
1 c
3 e
3 f
3 g
3 h
1 a
1 b
1 c
3 e
3 f
3 g
3 h
1 a
1 b
1 c
3 e
3 f
3 g
3 h

:?: :?: :?: :?:
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Help with for loop

Post by CesarePlay »

Yes. Thats exactly what is happening but when you go into sql the data is not duplicated there. It is only duplicating on the table in the application.
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Help with for loop

Post by RuadRauFlessa »

But which one. Does it write one row multiple times before going on to the next or does it write everything and then repeat it?
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Help with for loop

Post by CesarePlay »

RuadRauFlessa wrote:But which one. Does it write one row multiple times before going on to the next or does it write everything and then repeat it?
It writes everything down and then repeats it in the risks table. The other two tables are fine. It is only the risks table getting this problem.
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Help with for loop

Post by RuadRauFlessa »

have you run

Code: Select all

'GET RISKS
                Dim strSQL1 = "SELECT _SAFETY_Risks.*, _EMS_Reg_Impacts.IMPACT AS HAZARDDESC " & _
                        "FROM _SAFETY_Risks INNER JOIN " & _
                        "_EMS_Reg_Impacts ON _SAFETY_Risks.HAZARD = _EMS_Reg_Impacts.ID " & _
                        "WHERE (_SAFETY_Risks.REC_COUNT = 0) AND (_EMS_Reg_Impacts.REC_COUNT = 0) AND ASPECTID = '" & lstItems.SelectedItem.Value & "'"
this query in SSMS ?
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Help with for loop

Post by CesarePlay »

Yes. No duplicate entries were found.
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Help with for loop

Post by RuadRauFlessa »

CesarePlay wrote:Yes. No duplicate entries were found.
Sorry that was propably the most retarted thing I could have asked.
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Help with for loop

Post by RuadRauFlessa »

What is the value of txtNumRisks.Text when you get to lstHazards.Items.Clear() :?:
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
Post Reply