|
I suppose your dateformat on the SQL server isnt 'd/m/yy' so it recognized it as 'something' but cant make a valid date out of it. So it gets inserted as 'empty' date which resolves to 1/1/1900.
I keep submitting “VB” as a Priority-1 bug, but apparently no one here knows how to fix it. Nick Hodapp, Semicolon
|
|
|
|
|
Tip:- to save confusion when using dates in MSSQLServer, always use the format like this:-
YYYY-MM-DD HH:MM:SS
eg
'2002-11-05'
or
'2002-11-05 16:35:00'
this really helps to eliminate date ordering oddness.
Signature space for rent. Apply by email to....
|
|
|
|
|
I close a database using:
database.OpenEx(mySql,CDatabase::noOdbcDialog) ...
...more code...
database.Close();
but it remains existing. I have read it is also needed to destroy the object,, how can I do it?
Thanks.
|
|
|
|
|
Set database = Nothing (in straight asp)
|
|
|
|
|
Well, it is an MFC app, this way:
void OnExcel(CString sExcelFile)//, CString ficheroSolo)
{
CDatabase database;
CString sDriver ;//= "MICROSOFT EXCEL DRIVER (*.XLS)";
sDriver = GetExcelDriver();
CString sSql;
TRY
{
// Build the creation string for access without DSN
sSql.Format("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\"%s\";DBQ=%s", sDriver, sExcelFile, sExcelFile);
// Create the database (i.e. Excel sheet)
if( database.OpenEx(sSql,CDatabase::noOdbcDialog) )
{
// Create table structure
sSql.Format( "CREATE TABLE Graficas (Fecha TEXT, Hora NUMBER,[Temperatura (ºC)] NUMBER,[Rocío (ºC)] NUMBER,[Presión (mb)] NUMBER,[Velocidad (km/h)] NUMBER,[Dirección (º)] NUMBER,Brújula TEXT)");
database.ExecuteSQL(sSql);
}
...more code ...INSERT INTO, etc ....
database.Close();
|
|
|
|
|
When the your function ends, the CDatabase object is destroyed because it passes out of scope. There's no need to destroy it yourself, unless you created it with new , in which case you'll have to delete it.
|
|
|
|
|
Ok, ok. You're right. It was my mistake.
Thank you, very much.
|
|
|
|
|
How to do this using SQL-DMO? Subscriber and publisher status is needed.
I keep submitting “VB” as a Priority-1 bug, but apparently no one here knows how to fix it. Nick Hodapp, Semicolon
|
|
|
|
|
Hi all
I'm not sure what todo....I think I need a function...
This is my problem: I have a table called [References] with a [Rating] (tinyint) field. This field can be NULL or be 1,2,3,4,5 (stars ). Now what I wanna do is get an average of all non-NULL data where the [PersonID] (bigint) field equals a value from a SELECT query. OK I think I need to visualize
Table [References]:
[ID] bigint, (PK)
[PersonID] bigint,
[Rating] tinyint
Table [Users]:
[ID] bigint, (PK)
[Name] varchar(50),
[Role] int
Now I want the data to displayed as follows:
Output Table:
[Users.Name],
[References.AvgRating] ??????
where say [Role] = x
AS you can see I'm clueless but please help me
Cheers
"There are no stupid question's, just stupid people."
|
|
|
|
|
AVG is what you're looking for.
Get the statement w/all the joins together, and just select AVG([Rating]) out of it.
"The greatest danger to humanity is humanity without an open mind." - Ian Mariano
http://www.ian-space.com/
|
|
|
|
|
Thanx, I actually had a problem in the DB (wasnt set to allow NULLs (make mental note: stop coding drunk)). Anyways it does work, on its own, but in a more complex statement it doesnt... Well, actually 1 value is returned but no others...
Cheers
"There are no stupid question's, just stupid people."
|
|
|
|
|