[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

[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?
0
ddlam
Asked:
ddlam
1 Solution
 
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
 
ayha1999Commented:
Hi,

Are you trying to retrive from dynamic controls?

could u pls. post the html of the controls?

ayha
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
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:
thanks all, all the information are helpful
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now