Paul Clement
7/13/2010 7:24:00 PM
On Tue, 13 Jul 2010 04:27:37 -0400, "Joseph N. Stackhouse" <junkmauler@hotmail.com> wrote:
¤ The while reader.read returns no data at all (msgbox doesn?t even fire),
¤ there should be one row returned. When I execute this exact statement
¤ against the same access database within Microsoft Access I get my one row.
¤ Any ideas?
¤
¤ MsgBox("building sql")
¤ Dim SQLcmd As String = String.Format("SELECT TOP 1
¤ Suspects.Moniker FROM Suspects WHERE (((Suspects.Moniker) Like 'Unknown.*'))
¤ ORDER BY Suspects.Moniker DESC")
¤ Dim sVersion As String = vbNullString
¤ Dim SQLExec As New OleDbCommand
¤
¤ SQLExec.Connection = SpyBareDB
¤ SQLExec.CommandText = SQLcmd
¤
¤ Dim reader As OleDbDataReader = SQLExec.ExecuteReader()
¤ While reader.Read()
¤ MsgBox("getting string")
¤ MsgBox(reader.GetString(0))
¤ End While
Probably more of a SQL question. The wild-card character for ADO/OLEDB is a percent sign character
and not an asterisk (as when running the query from Microsoft Access).
If you need to run this query from Access as well then use the undocumented ALIKE keyword with the
percent sign as the wild-card character.
Paul
~~~~
Microsoft MVP (Visual Basic)