|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Parameters it doesnt work (for me)I have tried the code below to ask a question from an Access database, but I don't get any records wich I know I should. sökaOrdCom = New OleDbCommand("Select * from kött where köttid Like @KöttID", DBConn) sökaParam.ParameterName = "@KöttID" sökaParam.DbType = DbType.String sökaParam.SourceColumn = "Köttid" sökaParam.Value = "'" & PubStr & "*'" sökaOrdCom.Parameters.Add(sökaParam) Trace.WriteLine(sökaOrdCom.CommandText) sökaOrdRead = sökaOrdCom.ExecuteReader Do While sökaOrdRead.Read recCount += 1 'This code never happens Loop sökaOrdRead.Close() I have also tried the code below but I this isn't working either. sökaOrdCom = New OleDbCommand("Select * from kött where köttid Like @KöttID", DBConn) sökaOrdCom.Parameters.Add("@KöttID","'" & PubStr & "*'") Trace.WriteLine(sökaOrdCom.CommandText) sökaOrdRead = sökaOrdCom.ExecuteReader Do While sökaOrdRead.Read recCount += 1 'This code never happens Loop sökaOrdRead.Close() I thought that when you added the parameter the CommandText should look like this if PubStr = 'b' "Select * from kött where köttid Like 'b*'", but it doesnt it still looks the same. I have no idea why this isn't working. I hope some of you have. I miss the property RecordCount, isn't there any property like that in Visual Basic .NET or do you have to run a while loop to get the recordcount. PLEASE HELP!! Fia Hi,
The * is not a wild card character anymore use the % sign instead. Do not pass the ' into a parameter. This is what the parameters value should be. sökaParam.Value = PubStr & "%" Ken -------------- "Fia" <fiao***@telia.com> wrote in message I have tried the code below to ask a question from an Access database, but Inews:%23hqenHbOFHA.2532@TK2MSFTNGP09.phx.gbl... Hi don't get any records wich I know I should. sökaOrdCom = New OleDbCommand("Select * from kött where köttid Like @KöttID", DBConn) sökaParam.ParameterName = "@KöttID" sökaParam.DbType = DbType.String sökaParam.SourceColumn = "Köttid" sökaParam.Value = "'" & PubStr & "*'" sökaOrdCom.Parameters.Add(sökaParam) Trace.WriteLine(sökaOrdCom.CommandText) sökaOrdRead = sökaOrdCom.ExecuteReader Do While sökaOrdRead.Read recCount += 1 'This code never happens Loop sökaOrdRead.Close() I have also tried the code below but I this isn't working either. sökaOrdCom = New OleDbCommand("Select * from kött where köttid Like @KöttID", DBConn) sökaOrdCom.Parameters.Add("@KöttID","'" & PubStr & "*'") Trace.WriteLine(sökaOrdCom.CommandText) sökaOrdRead = sökaOrdCom.ExecuteReader Do While sökaOrdRead.Read recCount += 1 'This code never happens Loop sökaOrdRead.Close() I thought that when you added the parameter the CommandText should look like this if PubStr = 'b' "Select * from kött where köttid Like 'b*'", but it doesnt it still looks the same. I have no idea why this isn't working. I hope some of you have. I miss the property RecordCount, isn't there any property like that in Visual Basic .NET or do you have to run a while loop to get the recordcount. PLEASE HELP!! Fia
HLP: Retrieving ListView String Information
Question on updating data ?syntax to recognize code in a 2nd file Scripting Runtime ARRAYLIST ADDING A CLASS Checking a string for valid date sockets O.T.:Shameless Plug to get Free Software(for me & for you too) How to provide hint on sub params? Sequential file access and binary file access |
|||||||||||||||||||||||