[EASY] While Request.Form("ID" & i).count = 0

Code:
While Request.Form("ID" & i).count = 0

Error:
Compiler Error Message: BC30456: 'count' is not a member of 'String'.

How to debug?
LVL 9
ddlamAsked:
Who is Participating?
 
dynamicrevolutionsCommented:
try this

        Dim i As Integer
        Dim sqlQuery0 As String
        For i = 0 To Request.Form.Count - 1

            If Left(Request.Form.Keys(i), 2) = "ID" Then

                sqlQuery0 &= "Insert into dbo.ExamResult values (1, " & Request.Form.Item(i) & ", '2005-04-17', '" & Request.Form("Grade" & Request.Form.Keys(i).Replace("ID", "")) & "');"

            End If

        Next

0
 
ddlamAuthor Commented:
I will get a number of ID such as ID1, ID2, ID3... etc but I don't actually know how many ID will be get.

So, I check "While Request.Form("ID" & i).count = 0" to add something if the ID is not NULL
0
 
ddlamAuthor Commented:
My code:

            While IsNull(Request.Form("ID" & i))
                  sqlQuery0 &= "Insert into dbo.ExamResult values (1, " & Request.Form("ID"+i) & ", '2005-04-17', '" & Request.Form("Grade"+i) & "');"
                  i += 1
            End While
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
ayha1999Commented:
Hi,

Are you trying to retrive from dynamic controls?

could u pls. post the html of the controls?

ayha
0
 
b1xml2Commented:
Assuming you have multiple IDs

as in page.aspx?ID=1&ID=2&ID=3&Grade=A&Grade=B&Grade=C

Dim ids As String() = Request.QueryString.GetValues("ID")
Dim grades As String() = Request.QueryString.GetValues("Grade")
Dim sb As New System.Text.StringBuilder
Dim i As Integer = 0
For Each id As String In ids
      i += 1
      sb.AppendFormat("INSERT INTO dbo.ExamResult VALUES(i,'{0}','{1}','{2}');",id,Now.ToString("yyyy-MM-dd"),grades(i - 1))
Next
0
 
laotzi2000Commented:
         While not Request.Form("ID" & i) is nothing
               sqlQuery0 &= "Insert into dbo.ExamResult values (1, " & Request.Form("ID"+i) & ", '2005-04-17', '" & Request.Form("Grade"+i) & "');"
               i += 1
          End While
0
 
ddlamAuthor Commented:
thanks all, all the information are helpful
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.