473,408 Members | 1,973 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,408 software developers and data experts.

very strange proble with access queyr and parameter

hi,
here is my code :
szQry = "SELECT SubCategory_ID , " & _
" Loc1.Description as Descrizione " & _
" FROM C_SubCategories " & _
" LEFT OUTER JOIN D_Localizations Loc1 " & _
" ON ( C_SubCategories.Description_ID = Loc1.Localization_ID
AND Loc1.Language_ID = @LanguageID ) " & _
" WHERE Category_ID = @CategoryID " & _
" AND StateActive = 1 " & _
" ORDER BY SubCatOrder "

now i set the szqry to the command and i set the parameter ....
if set first the @languageID paramater and then the @CategoryID then command
returns always 0 record.
but if i change the order and put first the @CategoryID and the @languageID
all work great !!!! Why ?
Does Access convert my query ? It's a problem of the outer join ????
very strange .......

any suggestion?
tnx in advance
andrew
Nov 18 '05 #1
2 1295
Hi,

I assume you are using named parameters and you use OleDbConnection and
OleDbCommand in your code. Point is that in .NET they don't support named
parameters but parameters are specified based on their position on query.
Means you set first the value for the first parameter, then for the second
and so on e.g it is only by parameter's position. Note that for
System.Data.OleDb classes '?' (question mark) is the parameter placeholder
in queries

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"Andrew" <as*@for.it> wrote in message news:2p************@uni-berlin.de...
hi,
here is my code :
szQry = "SELECT SubCategory_ID , " & _
" Loc1.Description as Descrizione " & _
" FROM C_SubCategories " & _
" LEFT OUTER JOIN D_Localizations Loc1 " & _
" ON ( C_SubCategories.Description_ID = Loc1.Localization_ID AND Loc1.Language_ID = @LanguageID ) " & _
" WHERE Category_ID = @CategoryID " & _
" AND StateActive = 1 " & _
" ORDER BY SubCatOrder "

now i set the szqry to the command and i set the parameter ....
if set first the @languageID paramater and then the @CategoryID then command returns always 0 record.
but if i change the order and put first the @CategoryID and the @languageID all work great !!!! Why ?
Does Access convert my query ? It's a problem of the outer join ????
very strange .......

any suggestion?
tnx in advance
andrew

Nov 18 '05 #2
here is the code ...
it's doesn't work ....!!!
if i change the order of the parameter it works

why ???

szQry = "SELECT SubCategory_ID , " & _
" Loc1.Description as Descrizione " & _
" FROM C_SubCategories " & _
" LEFT OUTER JOIN D_Localizations Loc1 " & _
" ON ( C_SubCategories.Description_ID = Loc1.Localization_ID
AND Loc1.Language_ID = @LanguageID ) " & _
" WHERE Category_ID = @CategoryID " & _
" AND StateActive = 1 " & _
" ORDER BY SubCatOrder "

' Create Instance of Connection and Command Object
Dim myConnection As New
OleDbConnection(HttpContext.Current.Application("C onnectionString"))
Dim myCommand As New OleDbDataAdapter(szQry, myConnection)

' Mark the Command as a Text
myCommand.SelectCommand.CommandType = CommandType.Text

' Add Parameters to QRY
Dim parameterLanguageID As New OleDbParameter("@LanguageID",
OleDbType.BigInt)
parameterLanguageID.Value = m_iLanguageID
myCommand.SelectCommand.Parameters.Add(parameterLa nguageID)

' Add Parameters to QRY
Dim parameterID As New OleDbParameter("@CategoryID",
OleDbType.BigInt)
parameterID.Value = iSectionID
myCommand.SelectCommand.Parameters.Add(parameterID )
Nov 18 '05 #3

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

Similar topics

4
by: Chris Mayers | last post by:
Hi, Hope someone can explain this... OK, here is the simplest subset of my code that shows the problem: I have a C# Method: Private void UpdateDataTable(DataTable myDT) {
1
by: tom | last post by:
Hey All, I have a subform that shows records in datasheet view, all sorted nicely. When I right-click on any column and choose "Sort Ascending", Access pops up an "Enter Parameter" box for a...
0
by: Mike Thomas | last post by:
We are running an Access 2000 application "Kitting" on a server running Windows 2000 and Citrix server. Earlier this week, we began receiving this error whenever anyone tried to open this or any...
6
by: Mårten Herberthson | last post by:
Introduction: As we all know, values of any class may be assigned to a reference of a superclass. This is simple polymorphism. So if you have a class A and a class B that inherits from A you can...
5
by: Amaryllis | last post by:
I'm trying to call a CL which is located on our AS400 from a Windows application. I've tried to code it in different ways, but I seem to get the same error every time. Does anyone have any clue...
10
by: Bernard Liang | last post by:
Consider the following excerpt below, with the included relevant declarations. Firstly, the lines marked with **, ***, **** at the beginning are not supposed to have those stars at the...
2
by: teddysnips | last post by:
We've been supporting a number of Access applications for a particular client for some years. Some of them were written by third parties, some by us (even one or two by me, though not this...
4
by: George Shawn | last post by:
Hi, I am running into an extremely frustrating problem and after hours of troubleshooting have not made any progress. When I try to use the ADO Command object to update a table, I receive the...
4
by: Gotch | last post by:
Hi, I'm getting a very strange behaviour while running a project I've done.... Let's expose it: I've two projects. Both of them use a Form to do some Gui stuff. Other threads pack up messages...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.