Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » MSSQL, default DB, datetime
MSSQL, default DB, datetime [message #35989] Mon, 16 April 2012 16:52 Go to next message
Assargadon is currently offline  Assargadon
Messages: 11
Registered: August 2011
Location: Russia, Vladimir
Promising Member

I have two questions:
1. I am connected to MS SQL 2008 under the user sa (administrator).
By default for this user is definedr "master" DB.
In case of connection with a string
 cs = "Driver={SQL Server Native Client 10.0};Server=127.0.0.1;UID=sa;PWD=pswd;Database=Piramida2000;"

server makes connection, but all requests all the same go to a DB "master". I can't understand why requests go not to a DB "Piramida2000". if a default DB for user "sa" to change on "Piramida2000" all requests are executed correctly.
2. When I'm select:
Date sDate=GetSysDate(); 
Date eDate;
for(int j=0;j<=30;j++) 
{
eDate=sDate+1;
sql.Execute("select count(value0) from data where data_date>='?' and data_date<'?' and parnumber=12 and object=?", sDate, eDate, code[i]);
sql.Fetch();
sDate=sDate-1;
dayCount=sql[0];
DUMP(dayCount);         
}

than I see that in a dumping:
«select count(value0) from data where data_date>='04/11/2012' and data_date<'04/12/2012' and parnumber=12 and object=4369
ERROR [Microsoft][SQL Server Native Client 10.0]Attribute violation with restriction on data type(0): select count(value0) from data where data_date>='?' and data_date<'?' and parnumber=12 and object=?»

But in the SQL Management Studio this query ("select count(value0) from data where data_date>='04/11/2012' and data_date<'04/12/2012' and parnumber=12 and object=4369") is executed successfully
Re: MSSQL, default DB, datetime [message #36066 is a reply to message #35989] Mon, 23 April 2012 17:36 Go to previous message
Assargadon is currently offline  Assargadon
Messages: 11
Registered: August 2011
Location: Russia, Vladimir
Promising Member

Assargadon wrote on Mon, 16 April 2012 18:52


2. When I'm select:
Date sDate=GetSysDate(); 
Date eDate;
for(int j=0;j<=30;j++) 
{
eDate=sDate+1;
sql.Execute("select count(value0) from data where data_date>='?' and data_date<'?' and parnumber=12 and object=?", sDate, eDate, code[i]);
sql.Fetch();
sDate=sDate-1;
dayCount=sql[0];
DUMP(dayCount);         
}

than I see that in a dumping:
«select count(value0) from data where data_date>='04/11/2012' and data_date<'04/12/2012' and parnumber=12 and object=4369
ERROR [Microsoft][SQL Server Native Client 10.0]Attribute violation with restriction on data type(0): select count(value0) from data where data_date>='?' and data_date<'?' and parnumber=12 and object=?»

But in the SQL Management Studio this query ("select count(value0) from data where data_date>='04/11/2012' and data_date<'04/12/2012' and parnumber=12 and object=4369") is executed successfully

The question 2 was solved so:
selQuery<<"select count(value0) from data where data_date>='"<<sDate<<"' and data_date<'"<<eDate<<"' and parnumber=12 and object="<<code[i]; 
sql.Execute(selQuery);

Previous Topic: Sticky problem : MySql and UTF8
Next Topic: Filling same SqlArray with different tables from database
Goto Forum:
  


Current Time: Sun Jun 23 01:23:17 CEST 2024

Total time taken to generate the page: 0.03971 seconds