Re: datetimepicker and sql
nobody will touch this with a ten foot pole I see... lol oh well, on to the books again for me...
Re: datetimepicker and sql
Greetings,
While I have not used the BETWEEN or been in SQL (oracle dates act a little differently)... this is one way to handle query string manipulation... to construct your query, you could use the String.Format() method and 'insert' the date values this way...
Code:
// query text without the date parameters, just place holders...
string rawQuery = "SELECT punches.Number, punches.Punchdate, employees.Name FROM employees CROSS JOIN punches WHERE punches.PunchDate BETWEEN '{0}' AND '{1}'";
// throw your date values into the placeholders to produce your executing query...
string filledQuery = String.Format(rawQuery, DateTime.Today.ToShortDateString(), DateTime.Today.ToShortDateString());
(of course, using yor datepicker values rather than DateTime.Today....)
Re: datetimepicker and sql
Thanks! I found several problems I had with my approach. First was that I was using the Query builder tool.. Which appears to insert all the quotes itself, so I was not able to isolate the values to concatenate with the string, second was a big duh. I had no "using system.data.sqlClient" because the query builder did not need it. that settled most of the problems.. It looks like I am running into format problems, which I will situate today. I appreciate that you where willing to give the answer to the question asked, without a lecture on security... Once I get the minor details worked out and fully understand what I am working with, and what both languages want.. I can then upgrade to parametrized statements. Thanks again!
ill update with a result once I get that far.
Current Problem... the path is not of legal form...
Any books anyone knows of that deal with SQL and C# together?
after further investigation... it looks like I overwrote my DB somehow? leave it to me to screw it all up this bad... and I cant get rid of all the linking to start over... what a nightmare...
-ben
Re: datetimepicker and sql
How about any books on C# that will give me the knowledge to put the two together?
I have read: Sam's Learn SQL in 10 minutes, which actually takes a few hours.
C# for dummies, which is pretty accurate for me lmao, however I assume that it leaves alot of important things out
Re: datetimepicker and sql
Here's what I do to get the SQL things working.
1) I get the query working in Sql Management studio.
2) I then form the same query in C#.
I use breakpoints and step through my code in the debugger (press F5 to start debugging).
That way I can look at the exact sql string and see if it's formed correctly (and matches the one that I tested in the sql management console).
Re: datetimepicker and sql
I'll have to give that a shot when I get home from work tomorrow. Its not all bad that I have to start over, because I need the practice making everything and jiving it yet... I have a hunch the earlier suggestion for getting the most basic functionality of my query was working, but I had already done the dammage.... therefor negated it.
so much for jumping right into it and figuring out what seemed to be something petty...
I truely am looking forward to understanding sql a lot farther than I am now, I see so many potential uses.... I have issues with working on code at night.... which is when I work.. if I try and solve a problem while I am working, possibly the distractions are too much, or its just a bad location all together.. generally everything I do gets re-written the next morning when I wake up. not to mention how frustrated I get, and then I make matters worse by studying harder on things I dont fully understand yet.... vicious cycle... thanks for hangin in with me.
-ben