0

I am trying to run a Linq-to-SQL query, but when the query is evaluated, I get the following exception:

System.Data.OleDb.OleDbException was unhandled Message=The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect. Source=Microsoft JET Database Engine ErrorCode=-2147217900 StackTrace: at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) 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.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader() at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult) at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries) at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source) at xxx.InventoryPopulator`2.Clear(String barcode) in F:\Projects\C#\xxx\xxx\InventoryPopulator.cs:line 38 [..etc..] InnerException: 

The debugger shows my query is:

SELECT [t0].[SupplierID] AS [Id], [t0].[SupplierSKU] AS [Sku], [t0].[LocalSKU] AS [LocalSku], [t0].[ManufacturersBarcode] AS [Barcode], [t0].[QuantityAvailable] FROM [inventorySupplier] AS [t0] WHERE [t0].[ManufacturersBarcode] = @p0 

And the Linq query which generates the above is:

var items = from item in this.supplierItems where item.Barcode == barcode select item; 

How do I fix my query?

3
  • Did you run the generated query against your database and see if it runs? Commented Jun 8, 2010 at 13:47
  • @Raja, I ran the query in MS Access and it seemed to run fine; no errors or anything were reported. Commented Jun 8, 2010 at 14:00
  • As SLaks says Linq to SQL can be used for SQL Server only. Try the provider he suggested. @SLaks I already gave a +1 for you. Commented Jun 8, 2010 at 14:09

1 Answer 1

1

LINQ to SQL can only be used with SQL Server.

To use LINQ against other databases, you need a LINQ provider, such as this one.

Sign up to request clarification or add additional context in comments.

2 Comments

I'm not quite sure how I can use this ... Can you provide an example?
Not offhand. You can also use an off-the-shelf provider, such as alinq.org.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.