Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ArrayList Retrieve Values

Status
Not open for further replies.

jennuhw

MIS
Apr 18, 2001
426
US
I created an arraylist differently than I have in the past. Now, I am having problems retrieving any information from the arraylist. Any ideas?

Code:
Dim CCConn = New System.Data.SqlClient.SqlConnection("server=server;uid=username;pwd=password;database=database")
        Dim CQSQL As String = "SELECT order_no, p21_order_view.customer_id, customer_name, item_id, qty_ordered, required_date, "
        CQSQL += "unit_price, extended_price, order_date FROM p21_customer_view, p21_order_view "
        CQSQL += "WHERE (p21_order_view.company_id = p21_customer_view.company_id AND "
        CQSQL += "p21_customer_view.customer_id = p21_order_view.customer_id) And p21_order_view.item_id='" & item & "' "
        CQSQL += "and quote_flag='Y'"

        'Throw New Exception(CQSQL)
        Dim CQCommand As New System.Data.SqlClient.SqlCommand(CQSQL, CCConn)
        Dim CQReader As System.Data.SqlClient.SqlDataReader

        Dim CQArray As New ArrayList()

        CCConn.open()
        Try
            CQReader = CQCommand.ExecuteReader()
            Do
                While CQReader.Read
                    Dim vals() As Object = New Object(CQReader.FieldCount) {}
                    CQReader.GetValues(vals)
                    CQArray.Add(vals)
                End While
            Loop While CQReader.NextResult()

        Finally
            CCConn = Nothing
        End Try

'details
        For x = 0 To CQArray.Count - 1 'newArr.GetUpperBound(0)
            Response.Write("<tr><td>" & CQArray(0)& "</td>") ' I have tried .tostring and cqarray(x,0) but nothing works
            'Response.Write("<td>" & cqarray(x,0) & "</td>")
            'Response.Write("<td>" & cqarray(x,0) & "</td>")
            'Response.Write("<td>" & cqarray(x,0) & "</td>")
            'Response.Write("<td>" & cqarray(x,0) & "</td>")
            'Response.Write("<td>" & cqarray(x,0) & "</td>")
            'Response.Write("<td>" & cqarray(x,0) & "</td></tr>")
        Next
 
I went about it a different way and added the query results as a string seperated by a comma. Then, I split the results. Thanks.
 
It seems to be ASP.NET question. Anyway, try this:

Response.Write("<table>")
For i As Integer = 0 To CQArray.Count - 1
'Response.Write("<Td>" & CQArray(i).ToString & "</Td>")
Response.Write("<tr><td>" & CQArray(i).ToString & "</td><tr>")
Next
Response.Write("</table>")

I assume that there are data in the arraylist
Also remove the try block. It is useless, unless you and at least one Catch ex as {exception type}
 
I am new to ASP.net, and I get confused easily on what is vb and what is asp. I did try what you said before I posted, but it didn't work. I did do a workaround that is working fine. Thanks!
 
Web Development -> ASP.NET
We use for that:
1. VB.NET or C# to code at 'code-behind', other classes, etc
2. Some xhtml at source view
3. XML at web.config

The .vb files are being compliled so the code is not visible.

I hope i asweared you a little.

"what is vb and what is asp"
Be a little more accurate-distinct or whatever. VB.NET and not vb, ASP.NET and not classic ASP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top