locked
Connecting multiple datasources and output to asp table problem. RRS feed

  • Question

  • User-846735434 posted
    See if the following code makes sense.
    I am trying to make a gui for uploadating items from one database (inventory) to another (web) with the user being able to view the fields that will change and potentially manually update these fields in the text box they appear in.
    This is my first asp.net project and second project using vb so any help or insight would be great.
    Currently I am getting warnings about my cell variables being used before being assigned a value which I don't understand and having problems filling the DataCenterTable info, it is quite a complex sql statment pulling alot of info...
    Any alternative solutions to this problem would be great to hear too.
    Thanks,
    
    
    Protected Sub Display()
            Dim DescriptionAdapter As New DailyUpdateTableAdapters.DescriptionTableAdapter
            Dim DescriptionDataTable As New DailyUpdate.DescriptionDataTable
            Dim DescriptionRow As DailyUpdate.DescriptionRow
    
            Dim ProductVariantAdapter As New DailyUpdateTableAdapters.ProductVariantTableAdapter
            Dim ProductVariantDataTable As New DailyUpdate.ProductVariantDataTable
            Dim ProductVariantRow As DailyUpdate.ProductVariantRow
    
            Dim DataCenterAdapter As New DailyUpdateTableAdapters.DataCenterTableAdapter
            Dim DataCenterDataTable As New DailyUpdate.DataCenterDataTable
            Dim DataCenterRow As DailyUpdate.DataCenterRow
    
            DescriptionAdapter.Fill(DescriptionDataTable)
            DataCenterAdapter.Fill(DataCenterDataTable)
            ProductVariantAdapter.Fill(ProductVariantDataTable)
    
            For Each DescriptionRow In DescriptionDataTable
                Dim myrow As TableRow
                Dim skuCell As TableCell
                Dim nameCell As TableCell
                Dim qtyCell As TableCell
                Dim newQtyCell As TableCell
                Dim saleCell As TableCell
                Dim priceCell As TableCell
                Dim newPriceCell As TableCell
                Dim msrpCell As TableCell
    
                skuCell.Text = DescriptionRow.SKU
                nameCell.Text = DescriptionRow.Name
    
                For I As Integer = 0 To DataCenterAdapter.GetData.Rows.Count - 1
                    If DescriptionRow.SKU = DataCenterRow.UPCCode Then
                        
                        newQtyCell.Text = (DataCenterRow.TotalStore_OnHand - 5)
                        If newQtyCell.Text < 0 Then
                            newQtyCell.Text = 0
                        End If
                        newPriceCell.Text = DataCenterRow.Web_Retail
                        msrpCell.Text = DataCenterRow.MSRP
                    End If
                Next
                For I As Integer = 0 To ProductVariantAdapter.GetData.Rows.Count - 1
                    If DescriptionRow.ProductID = ProductVariantRow.ProductID Then
                        qtyCell.Text = ProductVariantRow.Inventory
                        saleCell.Text = ProductVariantRow.SalePrice
                        priceCell.Text = ProductVariantRow.Price
    
                    End If
                Next
    
                myrow.Cells.Add(skuCell)
                myrow.Cells.Add(nameCell)
                myrow.Cells.Add(qtyCell)
                myrow.Cells.Add(newQtyCell)
                myrow.Cells.Add(saleCell)
                myrow.Cells.Add(priceCell)
                myrow.Cells.Add(newPriceCell)
                myrow.Cells.Add(msrpCell)
                myrow.Cells.Add(skuCell)
                Me.Table1.Rows.Add(myrow)
            Next
        End Sub
    Monday, August 22, 2011 3:03 PM

Answers

  • User3866881 posted

    Dim myrow As TableRow

    Your TableRow and TableCell  should be created by using  something like

    TableRow tr As New TableRow

    TableCell tc As New TableCell

    tr.Cells.Add(tc)

    Table.Rows.Add(tr)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 23, 2011 10:22 PM
  • User-846735434 posted

    To fix that I used 

    For Each ProductVariantRow In ProductVariantDataTable

    Now I am running into problems with how to display the null values that are in my one column.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 24, 2011 11:54 AM

All replies

  • User-846735434 posted

    I noticed most people's threads were replied to very quickly. Maybe this is in the wrong section. Please advise.

    Tuesday, August 23, 2011 8:35 AM
  • User3866881 posted

    Dim myrow As TableRow

    Your TableRow and TableCell  should be created by using  something like

    TableRow tr As New TableRow

    TableCell tc As New TableCell

    tr.Cells.Add(tc)

    Table.Rows.Add(tr)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 23, 2011 10:22 PM
  • User-846735434 posted

    Ok, thanks that worked for them but now I am getting the same error for the ProductVarientRow and DataCenterRow. I am guessing this is what is causing my second to fills to fail. At this point the first two columns are showing but everything after is not.

    Wednesday, August 24, 2011 9:53 AM
  • User-846735434 posted

    To fix that I used 

    For Each ProductVariantRow In ProductVariantDataTable

    Now I am running into problems with how to display the null values that are in my one column.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 24, 2011 11:54 AM