简体   繁体   中英

Connecting console application to access database problems

I am trying to connect a console application to a access database.

This is the query that i have am using:

"SELECT [Type], [Name], [Phone Number], [Start Time], [End Time], [IM Session File], [Notes] FROM [Call History] WHERE [Start Time] >= ?"

The problem is that for some reason when i take that data from the access database and put it into a sql server database the dates are messed up in the sense that they are not in order of the year.

So i decided to add a order by clause:

SELECT [Type], [Name], [Phone Number], [Start Time], [End Time], [IM Session File], [Notes] FROM [Call History] WHERE [Start Time] >= ? ORDER BY [Call History].[Start Date]

command.Parameters.Add("@date", OleDbType.Date); command.Parameters["@date"].Value = calllogClient.getLastEntryInserted(ssid);

Keep getting this exception: System.Data.OleDb.OleDbException: No value given for one or more required parameters.

I don't know how to make this work. Any suggestions would be helpful.

Thanks

When setting the parameter, remove the @

command.Parameters["date"].Value = calllogClient.getLastEntryInserted(ssid);

I believe your select statement should be like this:

SELECT [Type], [Name], [Phone Number], [Start Time], [End Time], [IM Session File], [Notes] FROM [Call History] WHERE [Start Time] >= @date ORDER BY [Call History].[Start Date]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM