丢失数据持续 [英] Losing Data Continued

查看:168
本文介绍了丢失数据持续的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本程序是XSD文件里:

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.

最后的形式只有Load事件,仅此而已。

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

目前没有任何一行。

推荐答案

您的变量是走出去的范围。既然你已经声明(灰色)函数内的变量,它们被清理,只要您的code退出该功能。

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

然后改变:

Dim ordTable As New DataTable

ordTable = New DataTable

您将能够从这种方法外部访问ordTable。

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

这篇关于丢失数据持续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆