가 나는 Linq에 - 투 - SQL 쿼리를 실행하려고하지만 쿼리가 평가 될 때, 나는 다음과 같은 예외를 얻을 :Linq-to-SQL이 잘못된 SQL을 생성합니까?
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:
은 디버거를 보여줍니다 내 쿼리는 다음과 같습니다
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
그리고 위의 생성하는 Linq 쿼리는 다음과 같습니다.
var items = from item in this.supplierItems
where item.Barcode == barcode
select item;
내 쿼리를 어떻게 수정합니까?
데이터베이스에 대해 생성 된 쿼리를 실행하고 실행되는지 확인 했습니까? – Raja
@Raja, 나는 MS Access에서 쿼리를 실행했고 제대로 실행되는 것 같았습니다. 오류 또는 아무 것도보고되지 않았습니다. – strager
SLaks에 따르면 Linq to SQL은 SQL Server에만 사용할 수 있습니다. 그가 제안한 공급자를 시도하십시오. @ Slaks 이미 +1을주었습니다. – Raja