473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Parameters it doesnt work (for me)

Fia
Hi
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
Nov 21 '05 #1
1 1101
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" <fi*****@telia.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi
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

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: | last post by:
Hi, I was performing SQL UPDATE queries and I notice that they SUCCEED on the ExecuteNonQuery() call with NO exceptions raised BUT they fail at the Database. They say they succeed in the code...
3
by: Simon Harvey | last post by:
Hi everyone, I'm having a very frustrating problem executing a stored procedure. I'll put the code at the bottom. When I build the SP and add all the parameters everything goes as expected....
1
by: Station Media | last post by:
Hi, here my problem, i use stored procedure in ACCESS database(latest version), and i would like to use this procedure but it doesnt work, do you know why ? Procedure: PARAMETERS MyField Text...
2
by: siromega | last post by:
Hello all, I'm having a problem with XSL:Sort. I've parameterized it (and use javascript to populate the parameters, but that part is working fine).. <xsl:sort select="*" /> The problem...
2
by: Jared Grant | last post by:
I am trying to find the value from some output parameters from a stored procedure. I have tried several different methods but somehow cannot get it to work. here is my source code: dim dr as...
2
by: csmith8933 | last post by:
How do I write a function where the number of parameters it takes varies? This is what I have but it doesnt work. // function prototype void functionThree(int num1=1, int num2=2, int num3=3);...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.