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 =
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