Question

I am trying to add a parameter to my table adapter in my C# project. When I add the @ to the where clause visual studio gives me an error. Here is my SQL statement:

select PO.PO_Num,
  PO.Supplier,
  PO.DateOrdered,
  PO.DateRequired,
  PO.Terms,
  PO.Freight,
  PO.FOB,
  POItems.PO_Num as Expr1,
  POItems.Quantity,
  POItems.Description,
  POItems.Item,
  POItems.Price,
  POItems.KeyNum
from PO,
  POItems
where PO.PO_Num = POItems.PO_Num
  and (PO.PO_Num = @PO_Num)

Can someone please tell me what I am doing wrong? Thanks in advance for any help!

Was it helpful?

Solution

To fix the error I needed to change the where clause from this:

where PO.PO_Num = POItems.PO_Num and (PO.PO_Num = @PO_Num)

And add a question mark (?) in stead of the at symbol (@) like so:

where PO.PO_Num = POItems.PO_Num and (PO.PO_Num = ?)

After that I was able to execute the query, and Visual Studio 2010 didn't throw an error.

OTHER TIPS

I just came across this problem when adding a table adapter and using a data source of .NET framework Data provider for oracle. The two solutions of changing the where clause to use "@" and "?" didn't work for me.

Instead, I had to use the following:

where PO.PO_Num = POItems.PO_Num and (PO.PO_Num = :PO_Num)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top