|
The display format is independant of the way the date gets stored in Access. The default display format depends on your locale settings. To write dates to access (or any database, for that matter) the best approach is to use parameterised queries, and pass the date as a parameter of oledbtype.Date, which maps directly to System.DateTime (access uses the double seconds since 1899 as its storage type).
To display the date, you could specify the format:
<code>
date_txt.Text = System.DateTime.Today.ToString("dd/MM/yyyy")</code>
To display a date between two dates, use a parameterized query:
<code>string myQuery = "Select * from MyTable where MyDateField Between ? and ?"
OledbCommand myCommand = new OleDbCommand(myQuery, mYDbConnection);
myCommand.Parameters.Add("@StartDate",startingDateTime);
myCommand.Parameters.Add("@EndDate",endingDateTime);
OleDbDataReader dr = myCommand.ExecuteReader;
while(dr.Read())
{
...
}</code>
<small><b>Absolute faith corrupts as absolutely as absolute power<i>
Eric Hoffer</i></b></small>
<small><b>All that is necessary for the triumph of evil is that good men do nothing.
<i>Edmund Burke</i></b></small>
|
|
|
|
|
Thanks for your code. Could you tell me how to declare the variable as OleDbType.Date please, because I tried that, and it says that OleDbType.Date is a field but not a class. Therefore I still don't know how to pass the date as a parameter. Also, if I want to change the local settings, where can I find it please?
Thanks in advance
Asura
|
|
|
|
|
Are you sure that you can't use a date with that format with Access? That date format follows the ISO 8601 standard, and it is unambigous. I have never had any problems with that date format.
The dd/MM/yyyy format on the other hand is ambigous. The date 03/08/2005 can be interpreted either as 2005-08-03 or 2005-03-08.
I am not convinced that it's the date format that is the problem. How do you enter the date into the database?
---
b { font-weight: normal; }
|
|
|
|
|
I used a number of ways of writing the date information back into the database. For example,
DataTable table = ds.Table["Customer"];
table["date"] = System.DateTime.Today.Date.ToString("dd/MM/yyyy");
||
table["date"] = Convert.ToDateTime(System.DateTime.Today.Date.ToString("dd/MM/yyyy"));
||
table["date"] = System.DateTime.Parse(date_str);
I try the above ways, but none of them works.
Could you tell me how you enter the date into the database please??
Asura
|
|
|
|
|
Each of the methods you tried involved converting a string to a date. That means that you rely on the culture specified by default to correctly interpret the date. Obviously the default culture is not the one you wish to use, so it doesn't.
Provide a DateTimeFormat for the culture you wish to use. I would use a swedish CultureInfo (LCID 1053) to parse a date in swedish format:
string dateString = "2005-08-05";<br />
table["date"] = System.DateTime.Parse(dateString, new CultureInfo(1053).DateTimeFormat);
---
b { font-weight: normal; }
|
|
|
|
|
Does somebody know if there's a way to retrieve information about windows accounts registered on a specific computer? (usernames would be enough)
Tks a lot
Lucio
|
|
|
|
|
|
you can use Network Management Functions to
get info like you want create group ,get group user,etc
Network Management Functions[^]
i dont know if .net have equivalent functionality
|
|
|
|
|
|
I was just wondering what you guys are using to protect the applications written in any language under the .Net Framework. Do you prefer the exe packers and crypters, or some other schemes?
Which scheme is the best to implement, and presents a good ratio between a price/time to implement/protection it offers?
Thanks.
|
|
|
|
|
Hi Damir,
Its realy difficult to protect a .NET Application, because the application is only IL-Code (with a win32 loader) and you can recreate the code of it really good.
Try Lutz Roeder's Reflector[^], for instance with the System.dll (Framework Namespace System).
One solution is to use a obfuscator. The obfuscator renames all variables and methodes in useless terms, like a12423.
But a have no tip for a special product.
A communication version (free for students and freeware authors) of the dotfuscator is part of visual studio 2003. See: http://preemptive.com/products/dotfuscator/Editions.html[^]
A free alternative is the Aspose Obfuscator/[^].
An other idee is to pack all used dll's in one stream and embedded this stream as embedded resource in the application. Unpack this stream at runtime and load the dlls from this unpacked memory. Its simple possible to crypt the embedded stream.
A example implementation is descript in the magazin Dr. Dobb's Journal March 2005.
Reducing the Size of .NET Applications[^]
Hope, it's help a bit
Niedzi
|
|
|
|
|
|
I have a form with FormBorderStyle set to Sizable , and no minimize or maximize buttons, and no ShowInTaskbar . It displays the default Windows Forms icon in the title bar, even if I set the Icon property to null in the constructor.
Is there a way to have a sizable dialog without that little icon in the caption? How?
Thanks!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
The only way to do it is to set the icon to an image that matches the color o the title bar. You can't not have an icon there.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
There are two other ways:
1st way:
It's most like the idea of Dave.
Use a icon where all pixel are transparent.
2nd way:
Set the borderstyle to sizeable Toolwindow. The caption bar is a bit smaller.
|
|
|
|
|
Lars Niedziolka wrote:
Set the borderstyle to sizeable Toolwindow. The caption bar is a bit smaller.
Yes, I know, but that's not what I'm looking for... thanks!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Yes, I had thought about an all-transparent icon, but it still leaves the text a little more to the right than usual.
I've seen resizable windows without an icon, but I don't know if they're .NET apps or not. For example the common Open dialog in Visual Studio (that's not .NET, but I remember seeing another window in Visual Studio which I cannot find).
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi Luis,
the solution is very simple.
Set the property ControlBox of the form to false.
-- Niedzi
|
|
|
|
|
Thanks, but I tried that too and it also hides the close button on the right of the caption bar.
Maybe it's not possible with the framework. Thanks anyway.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi all,
I need to update client machines with the correct time if it is inaccurate. The server I'm using will always have the correct time so I'll be using that as the source of correct time. The code below works most of the time but is an an hour off sometimes (daylightsavings time).
For example, If I change the date on a local to machine to Jan 2005, my code will update the time an hour ahead of where it should be. Any help would be appreciated.
Thanks,Paul
Code is below
using System;
using System.Runtime.InteropServices;
public void UpdateTime(DateTime ServerTime)
{
TimeZone localZone = TimeZone.CurrentTimeZone;
DateTime localTime = localZone.ToLocalTime(ServerTime);
TimeSpan localOffset = localZone.GetUtcOffset(localTime );
ServerTime = ServerTime.Add(localOffset);
SetTime(ServerTime);
}
[StructLayoutAttribute(LayoutKind.Sequential)]
private struct SYSTEMTIME
{
public short year;
public short month;
public short dayOfWeek;
public short day;
public short hour;
public short minute;
public short second;
public short milliseconds;
}
[DllImport("kernel32.dll")]
static extern bool SetLocalTime(ref SYSTEMTIME time);
private void SetTime(DateTime NewTime)
{
SYSTEMTIME st;
st.year = (short)NewTime.Year;
st.month = (short)NewTime.Month;
st.dayOfWeek = (short)NewTime.DayOfWeek;
st.day = (short)NewTime.Day;
st.hour = (short)NewTime.Hour;
st.minute = (short)NewTime.Minute;
st.second = (short)NewTime.Second;
st.milliseconds = (short)NewTime.Millisecond;
SetLocalTime(ref st);
}
|
|
|
|
|
Call javascript function in C# and C# fucntion or objects id javascript
Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.
|
|
|
|
|
Well, you can call C# stuff from a C# dll embedded in an HTML page. See this page[^] for more info.
Calling JavaScript from C#, that is something a little more involved. Perhaps you could compile the JavaScript using the Microsoft JScript.NET compiler, then call the .NET methods on the resulting JScript.NET dll.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Homosexuality in Christianity
Judah Himango
|
|
|
|
|
Hi,
I've tried to integrate a C# library in a C++ program I created using Visual C++ 6.0. I've been able to do this and make it work properly, but it seems the COM object in the C# library is never properly released and I have outrageous memory leaks. Since this C++ program is a service, it doesn't close each time I use it and the leaking just goes on and on. Does anybody have a clue how I could solve this problem?
Thanks a lot!
Francois Dubé
|
|
|
|
|
see System.Runtime.InteropServices.Marshal.ReleaseComObject();
You might need to do this in the Dispose method of your library...
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
My C# object is a COM Interop Object. I am using it in a C++ service. So basically it's the other way around, it's the C# object that doesn't get released.
|
|
|
|