|
|
Hi.
In a few words, I have to convert a string retrieved from an Access database to a DateTime object.
I thought I'll use the Convert.ToDateTime() method. But there's the risk that the conversion will fail because the format will not be recognized. I think that this method uses the DateTime format taken from Contol Panel - Language Settings, so this would be tricky if the settings are different on another machine.
What would you do in this case?
Thanks.
|
|
|
|
|
There is a DateTime.TryParse and a DataTime.TryParseExact in .net 2.0 These should help you converting strings to datetimes in .net.
Ben
|
|
|
|
|
May it works for u check.
DateTime.ParseExact();
eg:
DateTime.ParseExact("01/05/2003", "dd/MM/yyyy", new CultureInfo("en-GB"));
agian convert it to string using Tostring()
Means provide culture specific format
Karuna
|
|
|
|
|
Please don't cross post. It's not very polite.
|
|
|
|
|
How can i save .4544453647867456353756 in database. Which data type is used?
No round figure
thks
|
|
|
|
|
Use "Double" datatype
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
Satips wrote: Use "Double" datatype
Where ? In SQL or in Program ?
|
|
|
|
|
I managed upto 15 decimal place with float . Please Tell me a real time scenario where you will use such a big decimal value ?
|
|
|
|
|
I've checked followig table
CREATE TABLE TblC (Col1 int, Col2 varchar(5), Col3 decimal(38, 38))
INSERT INTO TblC VALUES(1 'AAA', '0.12345678901234567890123456789012345678')
Here max of 38 digits are inserted after decimal. having no integer portion.
Regards
KP
|
|
|
|
|
is it possible to use > operator for text fields in a WHERE statement ie:
SELECT * FROM tblmain WHERE tblmain.[Should Grade] > tblmain.[Week 1]
Where should grade and week 1 are single letter (A, B, C, D, E and U) fields and tblmain is a table containing these fields
note i have tried this already in vba... and it doesn't work just checking really if it is what i suspect it is
if not, any reasonable (by reasonable anything that can be done in access & vba) suggestions for a work around?
only way i can think of is having A=1 B=2 C=3 etc
|
|
|
|
|
It sure is possible, you just need to watch out for what happens if either field is NULL, and also be aware that "A" is not the same as "a" so you might want to force to upper case, of course, this might not be an issue depending on your constraints when entering the results.
-------------------------------------------
Damian - Insert snappy one-liner here.
|
|
|
|
|
Try comparing ASCII values of the characters
Regards
KP
|
|
|
|
|
Hi all,
I'm trying to create a "generic" hierarchical model to store simple parent/child relationships. The closest approximation to what I'm trying to end up with is strongly based on the file system model. In SQL, I've defined the following table:
- ID (auto-generated, unique, non-nullable)
- NAME (just a string to be displayed to the user)
- PARENT_ID
The one fundamental constraint above all others I want to enforce at the database level is that any PARENT_ID value, if it has a non-NULL value at all, must exist somewhere in the ID field in this table. There are other restrictions that would be nice to have, but I can live with having this one only as a starting point.
Ultimately, I want to be able to store something like this:
C:\TEST1\FOLDER1
C:\TEST1\FOLDER2
C:\TEST1\FOLDER2\SUBFOLDER1
C:\TEST2\FOLDER1
...as:
1, "TEST1", NULL
2, "FOLDER1", 1
3, "FOLDER2", 1
4, "SUBFOLDER1", 3
5, "TEST2", NULL
6, "FOLDER1", 5
For some reason, suggesting this sort of thing in primarily SQL-oriented newsgroups seems to make the natives want to break out the tar and feathers...I'm apparently "thinking too much like an older developer used to linked lists and pointers". Fine, maybe I can't see the forest for the trees, but this "simple" model (in my eyes), if I can get it to work, would provide me with all the flexibility I need.
Ultimately, I'm NOT interested in writing any convoluted recursive queries to walk back up the PARENT_ID chain for a given node/row. The most complicated thing I might do is draw a tree (in ASP.NET), starting at the top level only (listing those entries whose PARENT_ID is NULL), and fetch a node's children when that node is clicked (select those entries whose PARENT_ID matches the ID of the node clicked).
Is this approach going to work, or do I have to scrap this entirely and put myself through hundreds of pages of data modeling theory, as the SQL gurus elsewhere seem to be suggesting?
If this is workable, could some kind soul *please* show me a SQL script to create this table with the appropriate constraints in place--or at least tell me what to click in SQL Server 2005 Management Studio to establish the constraints. I can't figure that part out (defining the table is easy, it's defining the "must exist in the ID column" rule for the PARENT_ID column I'm struggling with).
I'll save the "what's with the animosity among SQL developers towards old-fashioned software developers" question for another thread...
|
|
|
|
|
Pretty UIs to click through be damned. I managed to define my table as:
CREATE TABLE CATEGORIES
(
CAT_ID int IDENTITY(1,1) NOT NULL,
PARENT_ID int NULL,
CAT_NAME VARCHAR(50) NOT NULL,
PRIMARY KEY(CAT_ID),
FOREIGN KEY(PARENT_ID)REFERENCES CATEGORIES (CAT_ID)
)
Thoughts welcomed anyway.
|
|
|
|
|
I am trying to retrieve random rows from a database that I have in access. I got the sql statement to give me the database in random order, but I want to retrieve only 3 random rows from the database. THis is what I have so far:
SELECT *
FROM Jurors
ORDER BY rnd();
Please Help
Thank you
Steve Vondras
Red Lake Nation
MIS Tech
svondras@redlakenation.org
|
|
|
|
|
Describe the Jurors table in terms of the fields that are used. Not describing the how the table is set up, isn't going to allow anyone to really help you.
"That's no moon, it's a space station." - Obi-wan Kenobi
|
|
|
|
|
The jurors table has only two fields and I want both to appear. THere are about 20 different jurors, and I want to be able to randomly select 2 of them.
Steve Vondras
Red Lake Nation
MIS Tech
svondras@redlakenation.org
|
|
|
|
|
What are the two fields? Are you trying to do all of this from within Access or do you have an app tied into the database?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
The two fields are FIRST and LAST name, and I am doing this from within access.
Steve Vondras
Red Lake Nation
MIS Tech
svondras@redlakenation.org
|
|
|
|
|
You should have an id field that is a primary key. You can query by the id field with the randomly generated number.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
if you are able to get random row.then why don't you pick TOP 3 rows from the output
|
|
|
|
|
Where do I put TOP 3 in at on this statement:
SELECT *
FROM jurors
ORDER BY rnd();
I am very new sql thank you for your help
Steve Vondras
Red Lake Nation
MIS Tech
svondras@redlakenation.org
|
|
|
|
|
Replace the * with TOP 3 ...
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Thank you for the help.
Steve Vondras
Red Lake Nation
MIS Tech
svondras@redlakenation.org
|
|
|
|