我有一个SQLite数据库,我正在查询RecordID字段中的最大值。当我在SQLite中运行它时,此查询有效,但我无法让VB返回值,我做错了什么?
Dim getMaxRecID As String = "SELECT MAX(RecordID) FROM String"
Using cmd1 As New SQLiteCommand(getMaxRecID, pConn)
cmd1.CommandType = CommandType.Text
Dim IDresults As Integer
Try
IDresults = cmd1.ExecuteNonQuery()
Catch ex As Exception
Throw
End Try
连接正确打开数据库,并将其显示为打开状态。没有错误,只是IDresults每次都返回0。
感谢您的帮助。
答案 0 :(得分:0)
这解决了它......
Dim ds2 As New DataSet
Dim da2 As SQLiteDataAdapter
Try
da2 = New SQLiteDataAdapter(getMaxRecID, pConn)
da2.Fill(ds2)
IDresults = ds2.Tables(0).Rows(0).Item(0)