![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2007
Posts: 24
Rep Power: 0
![]() |
sql query
Hello..
I use a class OleDbCommand When my program calls cmdUpdateReturn.ExecuteNonQuery(); program crashes. cmdUpdateReturn is an object of OleDbCommand. How can I print sql query string before calling ExecuteNonQuery() to debug it? The error I get is: System.Data.OleDb.OleDbException: Syntax error in date in query expression 'BookNo LIKE 'B00000000001' AND BarrowerID LIKE '2000-001' AND DateBarrowed =#marec 19, 2007# AND DateDue =#marec 19, 2007#'. It would be really great if someone could help Im not familiar with C#, been working with it for a few days Thanks for help Best regards |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Mar 2005
Posts: 300
Rep Power: 4
![]() |
I would guess that the date is in the wrong format like you put.
Easiest two ways to test, one is to create the same query in some sort of query browser (dependent on what Database you are using) and see if it works, other is try taking out predicates and see if it works, remove the date predicates and see what happens, if it works you know it's the dates that are causing issue, if not then must be something else that is wrong as well. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Nov 2006
Location: Kosovė/Prishtinė
Posts: 47
Rep Power: 0
![]() |
l2u,
Can you post your query? Then we'll try to fix it, and for error handling try to use try-catch-finally exception handling. |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Mar 2007
Posts: 24
Rep Power: 0
![]() |
Hey guys
Heres the command being built: cmdUpdateReturn = new OleDbCommand("UPDATE tblBarrowed SET DateRetured =@getDateRetured, DelayedDays =@getDelayedDays, Fines =@getFines, Notes =@getNotes, Returned =@getReturned, ModifyBy =@getModifyBy, DateModify =@getDateModify WHERE BookNo LIKE '" + sBookID + "' AND BarrowerID LIKE '" + sBarrowerID + "' AND DateBarrowed =#" + sDTBrrwd + "# AND DateDue =#" + sDTDue + "#" ,clsConnections.CN);The error happens when DateRetured is the same as DateBarrowed. I have no idea how to solve this.. Thanks for help again |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Nov 2006
Location: Kosovė/Prishtinė
Posts: 47
Rep Power: 0
![]() |
CSharp Syntax (Toggle Plain Text)
Which data type are DateBarrowed and DateDue? if they are DateTime why are the "#" in there? And can you post all the snippet for the parametrized queries that you have used. And please use text highlighter (see this link: http://www.programmingforums.org/for...hlighting.html) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SQL injection on an insert query. | TCStyle | Other Web Development Languages | 2 | Nov 5th, 2006 8:14 PM |
| Query and List, PhP Main Page Auto Listing of User Actio | Stryker | PHP | 1 | Aug 21st, 2006 4:40 PM |
| C# VS 2005 - SQL Query Parameters to an ODBC DataSource | jcrcarmo | C# | 3 | Apr 10th, 2006 4:58 PM |
| VB.net SQL query load time | Driest | Visual Basic .NET | 4 | Feb 17th, 2006 7:02 PM |
| What means 'Operation must use updateable query' ? | jonyzz | ASP | 6 | Sep 22nd, 2005 7:11 PM |