Re: Dynamic Arrays in ASP.NET?
- From: "tony dong" <itdong@xxxxxxxxxxx>
- Date: Thu, 8 Dec 2005 20:49:17 -0800
using arraylist insteal of array in dot net
tony
<tjonsek@xxxxxxxxxxxxxx> wrote in message
news:1134077802.393425.64000@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>I am converting an ASP page to asp.net. In this application, a user can
> enter a list of numbers, separated by commas. The relationship involved
> is 1 to M and I never know how many different numbers the user will
> enter.
> I am getting a 'specified cast not valid' error. While I'm not 100% it
> is the array, This is the block of code that I have narrowed down to
> causing the problem.
> I've spent some time reading on the net about the differences in arrays
> in vb.net and am wondering if the split function I am using isn't the
> best route to go.
>
> Please give any pointers about arrays or suggestions for what might
> cause that specific error message.
>
> In old ASP, my code looked like this:
> dim woPrefix
> dim aryWO
> dim I
> woPrefix = "ASHC"
>
> aryWO = split(session("WO"),",",-1)
>
> set rst1 = cmd1.Execute()
> For I = 0 to UBound(aryWO)
> if session("flgType") = "e" or Instr(1,session("WO"),"ASHC") then
> sqlCmd = sqlCmd + "Insert into contractOutWO Values(" &
> session("ID") & ",'" & aryWO(I) & "') "
> else
> sqlCmd = sqlCmd + "Insert into contractOutWO Values(" &
> session("ID") & ",'" & woPrefix & aryWO(I) & "') "
> end if
> Next
>
> This is what I have in my .NET app:
> Dim woPrefix As String
> Dim aryWO As Array
> Dim I As Integer
> woPrefix = "ASHC"
>
> aryWO = Split(txtWO.Text, ",", -1)
>
> SqlSelectCommand1.CommandType = CommandType.Text
> SqlSelectCommand1.CommandText = "Delete from
> contractOutWO where ID ='" & lblID.Text & "'"
> SqlSelectCommand1.ExecuteNonQuery()
> For I = 0 To UBound(aryWO)
> If ddlCOType.SelectedValue = "E" Or InStr(1,
> txtWO.Text, "ASHC") Then
> SqlSelectCommand1.CommandText =
> SqlSelectCommand1.CommandText + "Insert into contractOutWO Values('" &
> lblID.Text & "','" & aryWO(I) & "') "
> Else
> SqlSelectCommand1 =
> SqlSelectCommand1.CommandText + "Insert into contractOutWO Values('" &
> lblID.Text & "','" & woPrefix & aryWO(I) & "') "
> End If
> If Len(SqlSelectCommand1.CommandText) > 0 Then
> SqlSelectCommand1.ExecuteNonQuery()
> End If
> Next
>
.
- Follow-Ups:
- Re: Dynamic Arrays in ASP.NET?
- From: Cor Ligthert [MVP]
- Re: Dynamic Arrays in ASP.NET?
- References:
- Dynamic Arrays in ASP.NET?
- From: tjonsek
- Dynamic Arrays in ASP.NET?
- Prev by Date: Re: exception inside lock before lock body
- Next by Date: Re: C# and vb
- Previous by thread: Dynamic Arrays in ASP.NET?
- Next by thread: Re: Dynamic Arrays in ASP.NET?
- Index(es):
Relevant Pages
|