C# 2.0 + MS Access == Error

O

Omer

Hi,
I am using C# 2.0 along with MS Access database. All my queries are
working perfectly fine, but one inner join query is ocntinously
throwing. I ahve tried it both from code and running explicitly throw
query builder, but to no avail. Query is

"SELECT * FROM COMPANY_ITEM_PRICE as CIP
INNER JOIN ITEM as I ON I.ITEM_ID = CIP.ITEM_ID WHERE CIP.COMPANY_ID =
1 ORDER BY I.NAME"

The error its throwing is,

System.Data.OleDb.OleDbException: No value given for one or more
required parameters.
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior
behavior)
at
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)

Can anyone please tell me whats wrong iwth the query.
 
D

Dave Sexton

Hi,

I believe the error is indicating that one or more of the tokens that you are
using does not correspond with any of the DB objects that are currently in
scope.

Is COMPANY_ITEM_PRICE correct?

I'm not sure if this error would occur even when explicitly scoping an object,
such as I.ITEM_ID, but you should probably verify each field name as well and
check to make sure that the fields do exist on the tables that you're
referencing. e.g., Ensure ITEM exists, ITEM_ID is in ITEM and CIP, COMPANY_ID
is in CIP and NAME is in ITEM.

If you are completely sure that the query tokens are all correct, then try to
simplify the query just for the sake of debugging.

i.e., Does the following work for you?

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM

If so, then try:

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
WHERE COMPANY_ITEM_PRICE.ITEM_ID = ITEM.ITEM_ID

etc...
 
O

Omer

Hi Dave,
Thanks for your reply.
All the tokens are perfectly fine.

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
is working.
BUT
SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
WHERE COMPANY_ITEM_PRICE.ITEM_ID = ITEM.ITEM_ID

is giving me the same error. It seem as if Jet has some problem with
comparing two table fields. :(

Dave said:
Hi,

I believe the error is indicating that one or more of the tokens that you are
using does not correspond with any of the DB objects that are currently in
scope.

Is COMPANY_ITEM_PRICE correct?

I'm not sure if this error would occur even when explicitly scoping an object,
such as I.ITEM_ID, but you should probably verify each field name as well and
check to make sure that the fields do exist on the tables that you're
referencing. e.g., Ensure ITEM exists, ITEM_ID is in ITEM and CIP, COMPANY_ID
is in CIP and NAME is in ITEM.

If you are completely sure that the query tokens are all correct, then try to
simplify the query just for the sake of debugging.

i.e., Does the following work for you?

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM

If so, then try:

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
WHERE COMPANY_ITEM_PRICE.ITEM_ID = ITEM.ITEM_ID

etc...

--
Dave Sexton

Omer said:
Hi,
I am using C# 2.0 along with MS Access database. All my queries are
working perfectly fine, but one inner join query is ocntinously
throwing. I ahve tried it both from code and running explicitly throw
query builder, but to no avail. Query is

"SELECT * FROM COMPANY_ITEM_PRICE as CIP
INNER JOIN ITEM as I ON I.ITEM_ID = CIP.ITEM_ID WHERE CIP.COMPANY_ID =
1 ORDER BY I.NAME"

The error its throwing is,

System.Data.OleDb.OleDbException: No value given for one or more
required parameters.
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior
behavior)
at
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)

Can anyone please tell me whats wrong iwth the query.
 
D

Dave Sexton

Hi Omer,

I'd like to make sure that it's in fact the comparison that is failing. Does
the following work?

SELECT TOP 10 COMPANY_ITEM_PRICE.ITEM_ID, ITEM.ITEM_ID
FROM COMPANY_ITEM_PRICE, ITEM

(If you get a different error, of course, please post it. ;)

--
Dave Sexton

Omer said:
Hi Dave,
Thanks for your reply.
All the tokens are perfectly fine.

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
is working.
BUT
SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
WHERE COMPANY_ITEM_PRICE.ITEM_ID = ITEM.ITEM_ID

is giving me the same error. It seem as if Jet has some problem with
comparing two table fields. :(

Dave said:
Hi,

I believe the error is indicating that one or more of the tokens that you
are
using does not correspond with any of the DB objects that are currently in
scope.

Is COMPANY_ITEM_PRICE correct?

I'm not sure if this error would occur even when explicitly scoping an
object,
such as I.ITEM_ID, but you should probably verify each field name as well
and
check to make sure that the fields do exist on the tables that you're
referencing. e.g., Ensure ITEM exists, ITEM_ID is in ITEM and CIP,
COMPANY_ID
is in CIP and NAME is in ITEM.

If you are completely sure that the query tokens are all correct, then try
to
simplify the query just for the sake of debugging.

i.e., Does the following work for you?

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM

If so, then try:

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
WHERE COMPANY_ITEM_PRICE.ITEM_ID = ITEM.ITEM_ID

etc...

--
Dave Sexton

Omer said:
Hi,
I am using C# 2.0 along with MS Access database. All my queries are
working perfectly fine, but one inner join query is ocntinously
throwing. I ahve tried it both from code and running explicitly throw
query builder, but to no avail. Query is

"SELECT * FROM COMPANY_ITEM_PRICE as CIP
INNER JOIN ITEM as I ON I.ITEM_ID = CIP.ITEM_ID WHERE CIP.COMPANY_ID =
1 ORDER BY I.NAME"

The error its throwing is,

System.Data.OleDb.OleDbException: No value given for one or more
required parameters.
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior
behavior)
at
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)

Can anyone please tell me whats wrong iwth the query.
 
O

Omer

Hi Dave,
this is getting interested.

SELECT TOP 10 COMPANY_ITEM_PRICE.ITEM_ID, ITEM.ITEM_ID
FROM COMPANY_ITEM_PRICE, ITEM

gives me the same error.

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
works fine.

and
SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
WHERE COMPANY_ITEM_PRICE.ITEM_ID = ITEM.ITEM_ID

gives me the error again.
Dave said:
Hi Omer,

I'd like to make sure that it's in fact the comparison that is failing. Does
the following work?

SELECT TOP 10 COMPANY_ITEM_PRICE.ITEM_ID, ITEM.ITEM_ID
FROM COMPANY_ITEM_PRICE, ITEM

(If you get a different error, of course, please post it. ;)

--
Dave Sexton

Omer said:
Hi Dave,
Thanks for your reply.
All the tokens are perfectly fine.

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
is working.
BUT
SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
WHERE COMPANY_ITEM_PRICE.ITEM_ID = ITEM.ITEM_ID

is giving me the same error. It seem as if Jet has some problem with
comparing two table fields. :(

Dave said:
Hi,

I believe the error is indicating that one or more of the tokens that you
are
using does not correspond with any of the DB objects that are currently in
scope.

Is COMPANY_ITEM_PRICE correct?

I'm not sure if this error would occur even when explicitly scoping an
object,
such as I.ITEM_ID, but you should probably verify each field name as well
and
check to make sure that the fields do exist on the tables that you're
referencing. e.g., Ensure ITEM exists, ITEM_ID is in ITEM and CIP,
COMPANY_ID
is in CIP and NAME is in ITEM.

If you are completely sure that the query tokens are all correct, then try
to
simplify the query just for the sake of debugging.

i.e., Does the following work for you?

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM

If so, then try:

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
WHERE COMPANY_ITEM_PRICE.ITEM_ID = ITEM.ITEM_ID

etc...

--
Dave Sexton

Hi,
I am using C# 2.0 along with MS Access database. All my queries are
working perfectly fine, but one inner join query is ocntinously
throwing. I ahve tried it both from code and running explicitly throw
query builder, but to no avail. Query is

"SELECT * FROM COMPANY_ITEM_PRICE as CIP
INNER JOIN ITEM as I ON I.ITEM_ID = CIP.ITEM_ID WHERE CIP.COMPANY_ID =
1 ORDER BY I.NAME"

The error its throwing is,

System.Data.OleDb.OleDbException: No value given for one or more
required parameters.
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior
behavior)
at
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)

Can anyone please tell me whats wrong iwth the query.
 
D

Dave Sexton

Hi Omer,

I'm trying to figure out the cause of your initial problem by the process of
reduction. In other words, you had an SQL statement that didn't work and I'm
trying to reduce it over and over again until we find out why. I encourage
you to try this style of debugging for yourself in the future.

It seems that the problem is either the expression,
"COMPANY_ITEM_PRICE.ITEM_ID" or "ITEM.ITEM_ID", or both.

What do you get from the following two queries when they are executed
independently?

SELECT TOP 10 ITEM_ID
FROM COMPANY_ITEM_PRICE

SELECT TOP 10 ITEM_ID
FROM ITEM

How about the next two queries?

SELECT TOP 10 COMPANY_ITEM_PRICE.ITEM_ID
FROM COMPANY_ITEM_PRICE

SELECT TOP 10 ITEM.ITEM_ID
FROM ITEM

--
Dave Sexton

Omer said:
Hi Dave,
this is getting interested.

SELECT TOP 10 COMPANY_ITEM_PRICE.ITEM_ID, ITEM.ITEM_ID
FROM COMPANY_ITEM_PRICE, ITEM

gives me the same error.

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
works fine.

and
SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
WHERE COMPANY_ITEM_PRICE.ITEM_ID = ITEM.ITEM_ID

gives me the error again.
Dave said:
Hi Omer,

I'd like to make sure that it's in fact the comparison that is failing.
Does
the following work?

SELECT TOP 10 COMPANY_ITEM_PRICE.ITEM_ID, ITEM.ITEM_ID
FROM COMPANY_ITEM_PRICE, ITEM

(If you get a different error, of course, please post it. ;)

--
Dave Sexton

Omer said:
Hi Dave,
Thanks for your reply.
All the tokens are perfectly fine.

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
is working.
BUT
SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
WHERE COMPANY_ITEM_PRICE.ITEM_ID = ITEM.ITEM_ID

is giving me the same error. It seem as if Jet has some problem with
comparing two table fields. :(

Dave Sexton wrote:
Hi,

I believe the error is indicating that one or more of the tokens that
you
are
using does not correspond with any of the DB objects that are currently
in
scope.

Is COMPANY_ITEM_PRICE correct?

I'm not sure if this error would occur even when explicitly scoping an
object,
such as I.ITEM_ID, but you should probably verify each field name as
well
and
check to make sure that the fields do exist on the tables that you're
referencing. e.g., Ensure ITEM exists, ITEM_ID is in ITEM and CIP,
COMPANY_ID
is in CIP and NAME is in ITEM.

If you are completely sure that the query tokens are all correct, then
try
to
simplify the query just for the sake of debugging.

i.e., Does the following work for you?

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM

If so, then try:

SELECT TOP 10 * FROM COMPANY_ITEM_PRICE, ITEM
WHERE COMPANY_ITEM_PRICE.ITEM_ID = ITEM.ITEM_ID

etc...

--
Dave Sexton

Hi,
I am using C# 2.0 along with MS Access database. All my queries are
working perfectly fine, but one inner join query is ocntinously
throwing. I ahve tried it both from code and running explicitly throw
query builder, but to no avail. Query is

"SELECT * FROM COMPANY_ITEM_PRICE as CIP
INNER JOIN ITEM as I ON I.ITEM_ID = CIP.ITEM_ID WHERE CIP.COMPANY_ID =
1 ORDER BY I.NAME"

The error its throwing is,

System.Data.OleDb.OleDbException: No value given for one or more
required parameters.
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior
behavior)
at
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)

Can anyone please tell me whats wrong iwth the query.
 

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

Top