|
Ok so I'm constantly having problems with parameters that magically disappear when changing to a hard coded query. Should I switch back o using hard coded queries?
|
|
|
|
|
I don't think anyone has a clue what you're talking about.
What do you mean by "when changing to a hard coded query" and "parameters that disappear"??
|
|
|
|
|
Hi all,
i have an string of date like xx="4/14/2008";
when i am trying to convert it into date time by
System.IFormatProvider frmt = new System.Globalization.CultureInfo("en-US", true);
DateTime dt32 = DateTime.ParseExact(xx, "MM/dd/yyyy", frmt);
it is giving me dt32 as dt32 = {4/14/2008 12:00:00 AM}
in above case i dont want to have "12:00:00 AM" part can u please help me.. here
i tried to parse like this also..
DateTime.TryParse(xx, out MyDateTime1);
it also didnt help me here..
Please help me
Thanks alot in advance...
vikas da
|
|
|
|
|
tasumisra wrote: it is giving me dt32 as dt32 = {4/14/2008 12:00:00 AM}
The time part is always stored; it's not called a DateTime for no reason. You can suppress it when you display it by calling the ToString() overload, however.
Cheers,
Vikram.
The hands that help are holier than the lips that pray.
|
|
|
|
|
i have to perform comaprision of date without time
coz if time is there then some time my condition will fail as an exaple
if (mydatetime4.Date >= dt12.Date && dt12.Date >= MyDateTime2.Date)
so in above
if mydatetime4.Date =4/14/2008 11:30:00 am
and dt12=4/14/2008 12:00:00 Am
that time definitly it will fail but i do not have to care abt the time if date matches then i have process some code..
please help me here ..
vikas da
|
|
|
|
|
This will work:
if (mydatetime4.Date.ToShortDateString() >= dt12.Date.ToShortDateString() && dt12.Date >= MyDateTime2.Date.ToShortDateString())
My idea of ideal life : Eat, Sleep, Repeat
|
|
|
|
|
sorry sir .. it wont work coz in this case date are in string formate ... and we cant compare string like <= operator here....
vikas da
|
|
|
|
|
My mistake. This works for me.
string xx = "04/14/2008";<br />
System.IFormatProvider frmt = new System.Globalization.CultureInfo("en-US", true);<br />
DateTime dt32 = (DateTime.ParseExact(xx, "MM/dd/yyyy", frmt));<br />
<br />
DateTime dt33 = new DateTime();<br />
dt33 = Convert.ToDateTime(xx);<br />
dt33 = dt33.AddHours(1);<br />
if(dt33.Date == dt32.Date) {<br />
string s = "";<br />
}<br />
}
My idea of ideal life : Eat, Sleep, Repeat
|
|
|
|
|
definitly above will work fine but what i want ...
but this will not work for me coz i dont know how many hrs i need to add there ...
now i am telling you my requirement ..
i have date dt12 = {4/14/2008 3:20:22 PM}
this date must lies between the range of date
dt32 = {4/14/2008 12:00:00 AM}
and
MyDateTime2 = {4/8/2008 12:00:00 AM}
so in above scenario if am able to truncate the time part anyhow so i ll be able get the desired result else for this kinda case condition will always be false...
so please help me here to remove the time part without converting into the string ....
thanks alot for all these replies..
vikas da
|
|
|
|
|
What is your problem if you try to do this?
if(yourDate >= startDate && yourDate < endDate)
{
}
Cheers,
Vikram.
The hands that help are holier than the lips that pray.
|
|
|
|
|
|
Firat of all thanks alot for replying..
in all these example we have string formate, i too do have string formate of date ... but since we cant compare two dates keeping them in string formate that is my concern... thats y i am trying to get the date part only in datetime object
vikas da
|
|
|
|
|
did u try the formating via culture in .net
|
|
|
|
|
When you compare DateTime.Date property of two objects, the time component is never taken into account. So, it will compare just dates reagrdless of time value.
My idea of ideal life : Eat, Sleep, Repeat
|
|
|
|
|
Hi,
here is the summary:
1. a DateTime always contains a Date and a Time
2. if you are not interested in the Time part, then:
- make sure it always has the same value (use DateTime.Date for that)
- don't show it
3. don't use strings for date or datetime comparisons, use DateTime > DateTime
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi,
Please write the best approach to insert more than one lakh records at a time in to Sql Server. we should consider about the performance also. I am using C#.
Thanks in advance.
|
|
|
|
|
Elena2006 wrote: lakh
What does this mean ? It means 100,000 ? Try speaking English if you want to be clear.
The best way to insert a lot of records is to group them, so you don't call 100,000 stored procs. There's a lot written on this topic, all of it more indepth than you'll get from a forum reply. C# is kind of irrelevant, it's the DB that has to do to the heavy lifting.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Best option my experinece, Use the dataset and adapter.
if u do like, the query execution time is very short for insertion.
|
|
|
|
|
Forget using the DataAdpater. It inserts one record at a time.
Google for "C# SQL Server Bulk Load".
|
|
|
|
|
Hello folks,
I have a panel on a form with several other controls on it. The panel has to be a totally draggable over the form - and stop at that. Draggable only over the form! This is how I have implemented the drag and drop currently (see code block below). I need to ensure that the draggable panel doesn't tread beyond the form area irrespective of the form's size. I tried meddling with the height, location et all but then either it stops scrolling or doesn't come inside the form when i click.
can you please tell me how to ensure that the whole panel stays within the form(that is not even the corners go out of form)?
<br />
private void myDock_MouseUp(object sender, MouseEventArgs e)<br />
{<br />
isDragging = false;<br />
Invalidate();<br />
}<br />
<br />
private void myDock_MouseDown(object sender, MouseEventArgs e)<br />
{<br />
isDragging = true;<br />
clickOffsetX = e.X;<br />
clickOffsetY = e.Y;<br />
this.Invalidate();<br />
<br />
<br />
}<br />
<br />
private void myDock_MouseMove(object sender, MouseEventArgs e)<br />
{<br />
if (isDragging == true)<br />
{<br />
myDock.Left = e.X + myDock.Left - clickOffsetX;<br />
myDock.Top = e.Y + myDock.Top - clickOffsetY;<br />
this.Invalidate();<br />
<br />
<br />
}<br />
<br />
Invalidate();<br />
}<br />
<br />
Hoping for a solution,
-
Roger
|
|
|
|
|
I guess you can put check in the mouse move event whether panel's left, top, right, and bottom are less than that of your form's.
My idea of ideal life : Eat, Sleep, Repeat
|
|
|
|
|
you mean somethin like this??
if ((myDock.Left > this.Left) && (myDock.Top > this.Top) && (myDock.Bottom < this.Bottom) && (myDock.Right < this.Right))<br />
myDock is the panel and 'this' the form..
|
|
|
|
|
How can i display image of database in crystal report in visual studio 2005?
|
|
|
|
|
How can i display image of database in crystal report in visual studio 2005?
from that , what you are try to say man?
please present you question clear way for other help to you.
|
|
|
|
|
Hi!
I am using .Net 1.1. My application creates a thread to write to a file. At some conditions (e.g. User pressed Cancel button, it aborts the thread. The problem I am facing is if the code was at line
<br />
streamWriter = new StreamWriter(filename, false, Encoding.Unicode);<br />
and thread was aborted, the file cannot be written again.
Here is the log when the thread is aborted:
<br />
Thread was being aborted.<br />
at Microsoft.Win32.Win32Native.CreateFile(String lpFileName, Int32 dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, FileMode dwCreationDisposition, Int32 dwFlagsAndAttributes, IntPtr hTemplateFile)<br />
at Microsoft.Win32.Win32Native.UnsafeCreateFile(String lpFileName, Int32 dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, FileMode dwCreationDisposition, Int32 dwFlagsAndAttributes, IntPtr hTemplateFile)<br />
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy)<br />
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)<br />
at System.IO.StreamWriter.CreateFile(String path, Boolean append)<br />
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)<br />
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)<br />
<br />
Here is the log of exception I get when I try to overwrite the file:
<br />
at System.IO.__Error.WinIOError(Int32 errorCode, String str)<br />
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy)<br />
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)<br />
at System.IO.StreamWriter.CreateFile(String path, Boolean append)<br />
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)<br />
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)<br />
<br />
Is there any way I could assure that either the streanWriter initializes completely (because it is null due to Thread Aborted) or I could release the file?
Thanks for any help in advance
|
|
|
|
|