|
Please use the overloaded Parse method
DateTime.Parse Method (String, IFormatProvider, DateTimeStyles)
and specify the Format.
|
|
|
|
|
I used .. Convert.ToDateTime("31/01/2004",new CultureInfo("en-GB"))
But still getting the same error, I want to specify British Date Style..
???
Thanks
|
|
|
|
|
It works just fine when I try it.
Does your code look exactly like that?
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I have set the date value in the text box. I am trying to save in this way...
Convert.ToDateTime(txtname.Text,new CultureInfo("en-GB")).. txtname contains 31/03/2004
This is throwing the same error.
But again I hard-code the value of txtname.text with
Convert.ToDateTime("31/03/2004",new CultureInfo("en-GB"))
Its working fine..
What cud be the problem with the textbox?
Thanks
|
|
|
|
|
Have you tried to write out the value from the text box, so that you are sure that it is sent to the server correctly?
---
b { font-weight: normal; }
|
|
|
|
|
That's because your using the Convert class. Use the DateTime Parse method to do this:
DateTime newDate = DateTime.Parse("31/01/2004", new CultureInfo("en-GB"));
or
DateTime newDate = DateTime.Parse("31/01/2004", "dd/MM/yyyy", Application.CurrentCulture.DateTimeFormat);
also works.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks a lot, its working fine..
But wats the diff between Convert and DateTime class for this. It was working with a hardcoded string and not with a textbox?
|
|
|
|
|
When you're converting a string to any kind of object, if the object has a Parse method, use it. IMHO, it's always going to work better than the more generic methods in Convert. Also, Parse deals with whitespace and invalid character issues better. I've almost gotten away with never using Convert in any of my apps...
There is no difference between a TextBox's Text property and a String. The Text property returns a String object, so, the only possible problem is an input error in the TextBox. If you include leading and/or trailing spaces, tabs, incorrect formatting characters, ..., Convert might not work whereas Parse might.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Please stop double posting.
I just answered this question in the asp.net section.
---
b { font-weight: normal; }
|
|
|
|
|
I have a DataTable which contains Tree-Data with the following Rows
id: int
name: string
parentid: int
Now I need a way, to get only the TreeNodes which have child-nodes.
The SQL-Statement I would use.
SELECT id
FROM table
WHERE id IN
(SELECT parentid
FROM table)
Is there a way to get the same result with a DataView a DataRelation or something else?
Markus
|
|
|
|
|
I think the faster query would be
select distinct parentid from table where parentid is not null
Please use DataView.RowFilter to specify the filter.
Thanks,
Alomgir
|
|
|
|
|
The RowFilter takes an String where I specify something like this.
DataView.RowFilter = "id = 123";
but this would not help, as I know there can be no sub-query in the row-filter.
Can you give an simple example for the RowFilter
for this SQL-Command:
SELECT id
FROM table
WHERE id IN
(SELECT DISTINCT(parentid)
FROM table)
|
|
|
|
|
Please use the query
SELECT distinct parentid FROM table parentid is not null
The C# implementation will be something similar to the following. The code is not tested but the concept is there. Hope this helps.
DataSet ds = new DataSet();
SqlDataAdapter myda = new SqlDataAdapter("TreeView", "server=localhost;database=TreeDb;uid=sa;pwd=;");
myda.SelectCommand.CommandType = CommandType.StoredProcedure;
myda.Fill(ds, "Table");
SortedList slist = new SortedList();
DataView dv = new DataView();
dv.Table = ds.Tables["table"];
dv.AllowDelete = true;
dv.AllowEdit = true;
dv.AllowNew = true;
dv.RowFilter = "parentid <> null";
dv.RowStateFilter = DataViewRowState.ModifiedCurrent;
dv.Sort = "parentid DESC";
IEnumerator iterator = dv.GetEnumerator();
DataRowView drv;
System.Int32 i= 0;
while(iterator.MoveNext())
{
drv = (DataRowView)iterator.Current;
if (! slist.ContainsValue(dr["parentid"]))
{
slist.Add(dr["parentid"].ToString (), dr["table"].ToString ());
}
i++;
}
DataList1.DataSource = slist.GetValueList();
DataList1.DataBind();
Cheers,
Alomgir Miah
|
|
|
|
|
I'm sure there is a class to do what I want in the .NET Framework but I cannot remember what it is called right now.
I am writing a service that will sit and wait for a new file to appear in a specific directory. It will then process the file and move it to an archive directory.
I just need a pointer to the class/method that will allow me to watch the directory. My other solution is to read the contents of the directory every few seconds and process the files, but I am sure there is already a pre-existing solution that will do that for me.
Can any one point me in the right direction? Or is this a fictional class that I drempt up somewhere?
|
|
|
|
|
System.IO.FileSystemWatcher
---
b { font-weight: normal; }
|
|
|
|
|
That's fantastic. Thanks. It was exactly what I was looking for!
|
|
|
|
|
It is the FileSystemWatcher class. It responds to different events such as create, change, renamed etc.
|
|
|
|
|
Hi,
I'm trying to detect if XP themes are enabled or not in code (using .NET 2.0). This not as
easy as it seams, however. I thought Application.VisualStyleState would be
of a lot of help, but unfortunately, it was not.
Basically, I need something similar to this (pseudo-code that might look like VB to some ):
If LegacyOS Then ' Older browsers with no theme support: W2K, W98, WME
return False
ElseIf OsSupportsThemes Then ' For example: XP, 2k3, Longhorn
If ThemesEnabled Then ' Application.EnableVisualStyles was called, or manifest is present
Return True
Else
Return False
End If
End If
Is there a method I'm not aware of in the .NET 2.0 framework, or a good way to do this?
Thanks!
Carl
|
|
|
|
|
Checkout the Environment class.
if(Environment.OSVersion.Platform == PlatformID.Win32NT &&
Environment.OSVersion.Version.Major >= 5 &&
Environment.OSVersion.Version.Minor >= 1) {
Application.EnableVisualStyles();
}
WM.
What about weapons of mass-construction?
|
|
|
|
|
Ok... but if the user is using XP but running in Classic themes... that won't help
|
|
|
|
|
Sorry, I didn't mean to post anonymously!
|
|
|
|
|
It should savely ignore the call anyway
WM.
What about weapons of mass-construction?
|
|
|
|
|
Application.RenderWithVisualStyles ?
|
|
|
|
|
EXACTLY! It works... Too bad I didn't see this property before
Thanks a lot!
On another note, is it possible to get the THEME that is currently displayed? Would be useful for me to theme controls that I'm drawing from code.
|
|
|
|
|
Take a look at the API functions in uxtheme.dll. OpenThemeData gives you a handle to the theme currently displayed. You then pass this handle to all of these functions to draw themed controls.
I hope this helps.
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|