丢失数据继续

发布于 2024-10-13 03:03:25 字数 960 浏览 3 评论 0原文

该过程位于 xsd 文件内部:

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),
                              PrintContents(5),
                              PrintContents(6))

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

在离开该过程之前,我检查 DataSet 行,发现变量在那里。

在下一步中,它会转到一个表格,我可以在其中查看相关报告。

最后一个表单只有 Load 事件,没有其他事件。

没有任何行。

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),
                              PrintContents(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 .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魂ガ小子 2024-10-20 03:03:25

您的变量超出了范围。由于您已在函数内声明(变暗)变量​​,因此一旦您的代码退出该函数,它们就会被清除。

尝试将此行放在函数之外:

Private ordTable as DataTable

然后将:更改

Dim ordTable As New DataTable

为:

ordTable = New DataTable

然后您将能够从此方法外部访问 ordTable。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文