Whats wrong with my code (ADO-oledb-VB.net)

J

JR

hi,

The next code gives me no records back. if I do the same selection with
acces I have many records, depending on the param LiedNaam

Thanks Jan
sConnectionString ==> standaard connection string but public dimd

'-------------------------code starts
here-------------------------------------------------------------------

Public Shared Function GetLiedjesByName(ByVal LiedNaam As String) As
ArrayList

Dim sSelect As String = "SELECT ID, Titel, IIf([Duur] Is Null,0,[Duur]) AS
Tijd, UitvoerdersID, CD_ID, Plaats, iif(Taal is null,"""",Taal) as lang,
iif(Genre is null,"""", Genre) as lGenre FROM Liedjes WHERE (Titel LIKE ?)"

Dim CN As New System.Data.OleDb.OleDbConnection(sConnectionString)

Dim CMD As New System.Data.OleDb.OleDbCommand(sSelect, CN)

CMD.Parameters.Add("Naam", LiedNaam & "*")

CN.Open()

Dim Reader As System.Data.OleDb.OleDbDataReader = CMD.ExecuteReader

Dim Liedjes As New ArrayList

Do While Reader.Read()

Dim P As New Liedje

P.LiedID = Reader.Item("ID")

P.LiedTitel = Reader.Item("Titel")

P.Liedduur = Reader.Item("Tijd")

P.LiedUitvoerder = Reader.Item("UitvoerdersID")

P.LiedCDID = Reader.Item("CD_id")

P.LiedPlaats = Reader.Item("Plaats")

P.LiedTaal = Reader.Item("Lang")

P.LiedGenre = Reader.Item("lGenre")

Liedjes.Add(P)

Loop

CN.Close()

Return Liedjes

End Function
 
A

Armin Zingler

JR said:
The next code gives me no records back. if I do the same selection with
acces I have many records, depending on the param LiedNaam

CMD.Parameters.Add("Naam", LiedNaam & "*")

Wildcards in OLEDB are % and _ (not * and ?).


Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top