丢失数据继续
该过程位于 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的变量超出了范围。由于您已在函数内声明(变暗)变量,因此一旦您的代码退出该函数,它们就会被清除。
尝试将此行放在函数之外:
然后将:更改
为:
然后您将能够从此方法外部访问 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:
Then change:
to:
You will then be able to access ordTable from outside this method.