0
我發現了一個問題,可能是SQLite ADO.NET提供程序中的一個錯誤。Sqlite數據提供程序.net錯誤:不同的SQL響應命令提示符與SQLite ADO.NET提供程序
環境是Windows 7 Pro,使用Visual Studio 2012 Professional,使用Visual Basic.net & ADO.NET 2.0。數據提供程序版本1.0.66.0 - v2.0.50727。
測試我正在使用一個簡單的SQLite數據庫只有一個表(「操作」)。
的數據是這樣的:
ID|TYPE|CODE|SIGN|DATE
15|TE|MC_02|ACME|2007-02-13
132|TE|MC_02|ACME|2009-01-16
190|TE|MC_02|ACME|2011-02-18
596|M|MC_02|MA|2009-06-17
703|M|MC_02|MA|2009-11-30
796|M|MC_02|MA|2010-06-10
898|M|MC_02|NQ|2011-07-04
929|M|MC_02|NQ|2011-12-02
980|M|MC_02|NQ|2012-01-02
1011|M|MC_02|NQ|2012-06-29
1061|M|MC_02|NQ|2012-12-05
1062|M|MC_02|AB|2000-01-01
如果我運行下面的SQL SELECT語句命令提示符:
D:\DB>sqlite3 test.db
Sqlite>SELECT *, MAX(DATE) FROM operations WHERE CODE = 'MC_02' GROUP BY TYPE;
我有(正確):
1061|M|MC_02|NQ|2012-12-05|2012-12-05
190|TE|MC_02|ACME|2011-02-18|2011-02-18
相反,如果我使用下面的VB.net代碼(只是一個帶有按鈕的表單):
Public Class Form1
Dim arrSelect As New ArrayList
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim strConnection As String = "data source= D:\DB\test.db"
Dim strQuery As String = "SELECT *, MAX(DATE) FROM operations WHERE CODE = 'MC_02' GROUP BY TYPE"
Dim strRecord As String = ""
arrSelect = SelectSQL(strConnection, strQuery)
If arrSelect IsNot Nothing Then
For Each value As Array In arrSelect
strRecord = ""
For j As Integer = 0 To value.Length - 1
strRecord &= value(j) & "|"
Next
Console.WriteLine(strRecord)
Next
End If
End Sub
Function SelectSQL(ByVal strConn As String, ByVal strCommand As String) As ArrayList
Try
Dim SQLconnect As New SQLite.SQLiteConnection()
Dim SQLcommand As New SQLite.SQLiteCommand
SQLconnect.ConnectionString = strConn
SQLconnect.Open()
SQLcommand = SQLconnect.CreateCommand
SQLcommand.CommandText = strCommand
Dim SQLreader As SQLite.SQLiteDataReader = SQLcommand.ExecuteReader()
Dim listLoc As New ArrayList
Dim nc As Integer = SQLreader.FieldCount
Dim arrLoc() As Object
While SQLreader.Read()
ReDim arrLoc(nc - 1)
For j As Integer = 0 To nc - 1
arrLoc(j) = SQLreader.Item(j)
Next
listLoc.Add(arrLoc)
End While
SQLcommand.Dispose()
SQLconnect.Close()
Return listLoc
Catch ex As Exception
Return Nothing
End Try
End Function
End Class
你有這樣的結果(錯誤):
1062|M|MC_02|AB|2000-01-01
190|TE|MC_02|ACME|2011-02-18
任何人都已經碰到過這種情況?
這是數據提供程序的錯誤嗎?或者我做錯了什麼?
感謝您的回覆。對不起,我最後一次不能花太多時間來完成這項工作。我被傳遞給Data Provider v 1.0.84,並且在測試縮減的項目中似乎一切正常。當我有時間時,我會將它應用到真正的項目中。再次感謝你。問候。 – 2013-03-12 14:11:51