开发者

Losing Data Continued

开发者 https://www.devze.com 2023-02-05 11:11 出处:网络
This procedure is inside of the xsd file: Public Shared Sub AddRowData(ByVal sender As Object, ByVal e As System.EventArgs)

This procedure is inside of the xsd file:

Public Shared Sub AddRowData(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim myDataCol As DataColumn
    Dim myDataRow As DataRow
    Dim ordTable As New DataTable
    Dim newDataRow As DataTable.orderDataRow
    Dim myDataset As New DataSet("orderData")
    Try
        ordTable.AllowAddNew = True
        newDataRow = ordTable.NewRow
        ordTable.orderData.Rows.Add(PrintContents(0),
                              PrintContents(1),
                              PrintContents(2),
                             PrintContents(3),
                              PrintContents(4),
                              PrintCon开发者_如何学运维tents(5),
                              PrintContents(6))

    Catch ex As Exception
        MessageBox.Show(ex.Message, "AddRowData")
    End Try
End Sub

Before it leaves the procedure I'm checking the DataSet row and I see that the Variable are there.

In the next step it goes to a form on which I'm viewing the relative report.

The Last form has only the Load event, nothing else.

There there is no any row .


Your variables are going out of scope. Since you have declared (Dimmed) the variables within the function, they are cleaned up as soon as your code exits that function.

Try putting this line outside of the function:

Private ordTable as DataTable

Then change:

Dim ordTable As New DataTable

to:

ordTable = New DataTable

You will then be able to access ordTable from outside this method.

0

精彩评论

暂无评论...
验证码 换一张
取 消