Click here to Skip to main content
16,004,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everybody,
I have a table with the fields Logid(primery key), Name, Address,EnteranceTime,LeaveTime
I want to access the records where the 'leavetime is null' and 'difference of Enterance time and the current time is less than the time duration I specify'. I am trying to pass current time and the time duration as function parameters. Problem is I can't pass the parameters right way. The error is parameters mismatch.
SELECT Logid, Name, Address, Company, EnteranceTime, LeaveTime, CardId
FROM EnteranceLog
WHERE (LeaveTime IS NULL) AND (EnteranceTime - ? = ?)
In c# I am calling the query this way

TimeSpan timespan = getduration();
this.enteranceLogMissingPersonsTableAdapter.Fill(this.enteranceLogDataSet.EnteranceLogMissingPersons, DateTime.Now.ToString (), timespan.ToString () );
please guide me how can I overcome this error
Posted
Updated 28-Jan-10 5:01am

when u pass to parameter you must convert the parameter value...
like if u create a table and define column like
cur_time timestamp datatype then ...
first you create the object

SqlCommand cmd = new SqlCommand();
cmd.parameter.add("date",sqldbtype.timestamp);


i hope might you got some selp
 
Share this answer
 
You should use the DateDiff function in your SQL. In the code, just pass the duration. You can get the current date and time through GetDate in SQL.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900