Click here to Skip to main content
15,921,905 members
Home / Discussions / Database
   

Database

 
GeneralRe: Need Help to make SQL SERVER Query Pin
dishanf19-Jul-04 1:17
dishanf19-Jul-04 1:17 
GeneralRe: Need Help to make SQL SERVER Query Pin
dishanf19-Jul-04 1:28
dishanf19-Jul-04 1:28 
GeneralRe: Need Help to make SQL SERVER Query Pin
Arvind200419-Jul-04 3:32
Arvind200419-Jul-04 3:32 
Questionwhat is wrong with this query?... Pin
blankg16-Jul-04 22:42
blankg16-Jul-04 22:42 
AnswerRe: what is wrong with this query?... Pin
Daniel Turini16-Jul-04 23:55
Daniel Turini16-Jul-04 23:55 
GeneralRe: what is wrong with this query?... Pin
blankg17-Jul-04 2:38
blankg17-Jul-04 2:38 
GeneralRe: what is wrong with this query?... Pin
Daniel Turini17-Jul-04 3:10
Daniel Turini17-Jul-04 3:10 
GeneralSQL Query using date format problem!!! Pin
girl_lash16-Jul-04 0:26
girl_lash16-Jul-04 0:26 
ive been creating a query using date as one of its parameters. the date is of CTime data type.


my code is like this:
CString dbWorkName;
CString dbPICName;
CString dbElementName;
CTime dbDate;
CString readSQL;
double ReviewActualHour = 0;
CString strReviewActualHour;
CString ProjName;
CString strReviewDay;
SYSTEMTIME date;

dbDate.GetAsSystemTime(date);

strReviewDay.Format("%04d-%02d-%02d",date.wYear,date.wMonth,date.wDay);


_bstr_t bstrQuery;
_variant_t getFiled;
_variant_t vRecsAffected;

vRecsAffected = 0L;


readSQL = "SELECT L_EveryDay.username, T_ProjectName.project, T_ProjectDetailName.detail, T_OccasionName.occasion, L_EveryDay.ymd, Sum(L_EveryDay.difference)/60 AS TOTALHOUR ";
readSQL += "FROM T_OccasionName INNER JOIN (T_ProjectDetailName INNER JOIN (T_ProjectName INNER JOIN L_EveryDay ON T_ProjectName.seq = L_EveryDay.project) ON T_ProjectDetailName.seq = L_EveryDay.projectdetail) ON T_OccasionName.seq = L_EveryDay.occasion ";
readSQL += "GROUP BY L_EveryDay.username, T_ProjectName.project, T_ProjectDetailName.detail, T_OccasionName.occasion, L_EveryDay.ymd ";
readSQL += "HAVING (((L_EveryDay.username)=";
readSQL += '"';
readSQL += dbPICName;
readSQL += '"';
readSQL += ") ";
readSQL += "AND ((T_ProjectName.project) LIKE ";
readSQL += '"';
readSQL += '%';
readSQL += ProjName;
readSQL += '"';
readSQL += ") ";
readSQL += "AND ((T_ProjectDetailName.detail)=";
readSQL += '"';
readSQL += dbWorkName;
readSQL += '"';
readSQL += ") ";
readSQL += "AND ((T_OccasionName.occasion)=";
readSQL += '"';
readSQL += dbElementName;
readSQL += '"';
readSQL += "AND ((L_EveryDay.ymd)=";
readSQL += "#";
readSQL += strReviewDay;
readSQL += "#";
readSQL += "));";
bstrQuery = readSQL;
MessageBox(NULL, readSQL, "Test", MB_OK);

try
{
recordSet_ = connection_->Execute(bstrQuery,&vRecsAffected,adOptionUnspecified);

}
catch( _com_error &errMessage )
{
MessageBox(NULL, "failed", "Test", MB_OK);
TRACE(errMessage.Description());
TRACE(errMessage.ErrorMessage());
TRACE(bstrQuery);
}


When the program executes the query, runtime error appears. im having difficulty on how to format the date during the query. In MS Access, the date is enclosed with #. So, i tried the same way too. I tried so many times on formatting the date but no one returns the good result.. so for those, who have encountered the same problem as I am, please help me with this...

what should I do with my query?

thanks in advance
GeneralRe: SQL Query using date format problem!!! Pin
Mike Dimmick17-Jul-04 23:59
Mike Dimmick17-Jul-04 23:59 
GeneralRe: SQL Query using date format problem!!! Pin
EdbertP18-Jul-04 15:24
EdbertP18-Jul-04 15:24 
Generalquering on views Pin
blankg15-Jul-04 23:47
blankg15-Jul-04 23:47 
GeneralRe: quering on views Pin
Colin Angus Mackay15-Jul-04 23:57
Colin Angus Mackay15-Jul-04 23:57 
GeneralRe: quering on views Pin
blankg16-Jul-04 0:27
blankg16-Jul-04 0:27 
GeneralRe: quering on views Pin
Mekong River17-Jul-04 4:53
Mekong River17-Jul-04 4:53 
GeneralRe: quering on views Pin
blankg17-Jul-04 9:51
blankg17-Jul-04 9:51 
GeneralRe: quering on views Pin
Mekong River17-Jul-04 18:18
Mekong River17-Jul-04 18:18 
GeneralRe: quering on views Pin
blankg17-Jul-04 21:35
blankg17-Jul-04 21:35 
GeneralInput string was not in a correct format Pin
DotNet15-Jul-04 18:27
DotNet15-Jul-04 18:27 
GeneralRe: Input string was not in a correct format Pin
Colin Angus Mackay15-Jul-04 22:19
Colin Angus Mackay15-Jul-04 22:19 
GeneralRe: Input string was not in a correct format Pin
Colin Angus Mackay16-Jul-04 2:22
Colin Angus Mackay16-Jul-04 2:22 
GeneralRe: Input string was not in a correct format Pin
DotNet16-Jul-04 3:57
DotNet16-Jul-04 3:57 
Questioncan i get some operation infomation from SQLsrv2k ? Pin
fu015-Jul-04 15:58
fu015-Jul-04 15:58 
AnswerRe: can i get some operation infomation from SQLsrv2k ? Pin
RichardGrimmer15-Jul-04 23:28
RichardGrimmer15-Jul-04 23:28 
GeneralRe: can i get some operation infomation from SQLsrv2k ? Pin
fu017-Jul-04 15:39
fu017-Jul-04 15:39 
GeneralRe: can i get some operation infomation from SQLsrv2k ? Pin
RichardGrimmer19-Jul-04 5:40
RichardGrimmer19-Jul-04 5:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.