Private Function Gelobee() As DataSet Dim connection As OleDb.OleDbConnection = New OleDbConnection connection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=CMP.accdb" connection.open() Dim da As OleDb.OleDbDataAdapter = New OleDbDataAdapter("SELECT IDDesc FROM [ItemDesc] WHERE IDPartNo = '" & PartNoTxt.Text & "';",connection) Dim ds As New DataSet da.Fill(ds,"FilteredDesc") connection.dispose() connection = nothing If ds.Tables.Count > 0 Then If ds.Tables[0].Rows.Count > 0 Then DescTxt.Text = ds.Tables(0).Rows(0).Item(0) Else DescTxt.Text = "No Description" End If End If Return ds End Function
嗨,我正在尝试检查数据集是否有行.但是它给了我“ds.Tables [0] .Rows.Count> 0”的错误.我的代码有什么问题吗?我试图在网上搜索,但我似乎无法找到答案.
解决方法
用于访问索引器的VB.NET语法应该带括号…
If ds.Tables(0).Rows.Count > 0 Then
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。