|
Hi All,
Using VC6 I am connecting to a database via OLEDB/ODBC. My locale
regional settings are set to French while I investigate this problem.
When I read values from a table, I convert everything to strings like
the following:
m_pCommand->AddBindEntry(l+1, DBTYPE_WSTR, sizeof(TCHAR)*256,<br />
&m_pColumns[l].szValue, NULL, &m_pColumns[l].dwStatus);
So as you can see, all fields are bound to DBTYPE_WSTR
Now when I read a currency value or a numeric value with decimal
places, the value ALWAYS looks like this "23.23" when it should look
like "23,23" with my current regional settings. The decimal seperator
is a ',' and not a '.'
If I query the database with Access, Excel, Crystal Reports they always
give me the correct values with correct decimal seperators so I feel I
must be missing a trick.
I connect to the database like this:
CComPtr<IDBPromptInitialize> spDBInit;<br />
hResult = CoCreateInstance(CLSID_DataLinks, NULL, CLSCTX_INPROC_SERVER,<br />
IID_IDBPromptInitialize, (void**) &spDBInit);<br />
<br />
if (hResult != S_OK)<br />
return RES_DBCONNECTION_OPEN_DATALINKS;<br />
<br />
DBPROMPTOPTIONS dwPromptOptions = DBPROMPTOPTIONS_WIZARDSHEET;<br />
CComPtr<IDBProperties> spIDBProperties;<br />
<br />
hResult = spDBInit->PromptDataSource(NULL, m_hProgressDlg,<br />
dwPromptOptions, 0, NULL, NULL, IID_IDBProperties,<br />
(IUnknown**)&spIDBProperties);<br />
<br />
if (hResult != S_OK)<br />
{<br />
if (hResult == DB_E_CANCELED) {<br />
return RES_CANCELED;<br />
} else {<br />
ShowOLEDBErrors(hResult);<br />
return RES_DBCONNECTION_OPEN_DATALINKS;<br />
}<br />
<br />
}<br />
<br />
LCID locale = GetUserDefaultLCID();<br />
CDBPropSet dbInit(DBPROPSET_DBINIT);<br />
<br />
dbInit.AddProperty(DBPROP_INIT_HWND, (long int)m_hProgressDlg);<br />
dbInit.AddProperty(DBPROP_INIT_PROMPT, (short)DBPROMPT_COMPLETE);<br />
dbInit.AddProperty(DBPROP_COMMITPRESERVE, (bool)TRUE);<br />
dbInit.AddProperty(DBPROP_ABORTPRESERVE, (bool)TRUE);<br />
dbInit.AddProperty(DBPROP_INIT_LCID, (long int)locale);<br />
spIDBProperties->SetProperties(1, &dbInit);<br />
<br />
hResult = spIDBProperties->QueryInterface(&m_source.m_spInit);<br />
if (hResult != S_OK)<br />
{<br />
ShowOLEDBErrors(hResult);<br />
return RES_DBCONNECTION_OPEN_DATALINKS;<br />
}<br />
<br />
hResult = m_source.m_spInit->Initialize();
There is a microsoft article that I thought may be making things wrong
which is at
http://support.microsoft.com/defaul...;EN-US;Q320744& But
the resolutions suggested have made no effect.
Any suggestions that anyone could offer would be greatly appreciated.
Thank you,
Chris
|
|
|
|
|
I was able to create the file larger than 4 Gb. However, I want to be able to read the last line to see where it stopped. This code outputs the whole file but works when the file is less than 4Gb. What's wrong?
Thanks,
ifstream inClientFile ("diction.txt", ios::in);
inClientFile.seekg(-10, ios::end);
char w[30];
while (inClientFile>>w)
output(w);
void output(const char * const w)
{
cout<
|
|
|
|
|
i have another suggestion, independant from you (but i'm not sure)
isn't the streams (cout here) index on 32 bits ?
if so, even if you take the max value of an unsigned long , you'll be limited at position 4294967295 (4GB).
i don't think streams support __int64...
so if anyone have an idea to confirm/infirm my thinking...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
It does read the whole file. The only problem is that it reads the whole file regardless of the parameters. Does that constitute as supporting large file sizes?
|
|
|
|
|
I guess I stumped everyone.
|
|
|
|
|
Andrew Admire wrote:
I stumped everyone
NO you Can't
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
So, how can I fix the problem?
|
|
|
|
|
I know in php you can use AddSlashes to turn \ into \\ but how can I do this in c++ as I have not been able to find anything so far?
Thanks,
Matt
|
|
|
|
|
Are you referring to the PathAddBackslash() function.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I'm not totally sure. Basically I have a directory path which is just a single backslash and I need to change it to double so that ShellExecute will work properly.
|
|
|
|
|
Why does ShellExecute need \\ ?
How are you entering the string in your program? Is it a constant in your cpp file?
John
|
|
|
|
|
Actually I said the wrong thing, sorry. I am trying to get a value from my ini file and it wont find the ini file if its only \ which is why I wanted to convert it to \\
|
|
|
|
|
|
You should not need to do so. That is why I was confused. \\ is only needed if the string is compiled into your program or you are using a UNC server name such as \\mypc\share\file.txt instead of c:\file.txt. The reason why you need an extra slash in a compiled string is that \ is the escape character in c. The character that comes after the \ is gobbled up and converted into a code \n = new line \r = carrage return \t = tab. But how then do I use a \ in a string constant when I really want a \. The language writers added \\ = \ to allow this. When you read your data from any other method other than compiled into these conversions do not occur so you never need \\ in any type of file.
John
|
|
|
|
|
|
Without seeing the code that you are using, I don't fully understand the problem. Actually I'm not sure there is a problem. More likely it's just a misunderstanding of how backslashes in string literals work in C.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
the double slash is just a representation when you edit your code to say that you store the only character slash ('\\' = \) instead of an escape character.
for example, if you make this :
CString strPath = ".\nonoFolder" it will see \n and replace it as a CR-LF.
if you make instead CString strPath = ".\\nonoFolder" , there's no more problem.
i dont know how you get the path however, but if you get it from a "get folder" dialog, even if the user see only one slash, the storing string is correct...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Ok to remove confusion this is what I currently have:
//Get the current working directory
_getcwd( workingDirectory, _MAX_PATH );
printf( "%s\n", workingDirectory );
//Get the value from the ini file
GetPrivateProfileString("Auth", "Key", "", szAuth, sizeof(szAuth), "D:\\Programs\\Microsoft Visual Studio\\MyProjects\\Project12\\Debug\\Settings.ini");
What I want to do is take the working directory and put it into GetPrivateProfileString with \Settings.ini on the end. There is probably a better way than the way I am thinking of doing it so I am open to suggestions on doing it different ways.
|
|
|
|
|
Hello folks.I don't watch movies much but some days ago i brought a computer cd rom cd at home and inserted it in the cd room and a program started straight away which run that movie.I got an idea from there why not to write a program which behaves like that, i.e. it runs without triggering it.Any idea how to do this.
Regards.
Be FaithFull To Your Work.
|
|
|
|
|
|
The article you referred is concerned with autoplaying a movie whereas i asked about launching an application without triggering it and not about the execution of a movie in the context of autoplay.Hope you will help me.
Be FaithFull To Your Work.
|
|
|
|
|
|
This link is again executiong an applicatioin from cd.Suppose that you have written an application ( adding two number i.e,2+1=3 ) in VC 6 and you want that you trigger it without generating an event from user like double clicking it.Hope you understand.Is it possible if yes please help.
Be FaithFull To Your Work.
|
|
|
|
|
I'm not sure what you mean by "you trigger it without
generating an event from user like double clicking it"
When exactly do you want the program to run if there is
no event to trigger it, like loading from CD or double-clicking?
There must be some event to trigger it or otherwise how can the
operating system know when to run it?
Steve T
|
|
|
|
|
One way is to programmatically develop the application in such a way that whenever the computer starts it automatically runs itself.(Starts itself when the computer starts). This is very easy to do by putting a few lines of code in the application it sets it path in registry.But i am talking about the fact is there is OS service or utility which is in access of user so that the user can join his/her application with that utility of service of OS(windows).For example in Linux there is a utility or service from the name figure or finger ( something like that ) which allows us to do so.
Be FaithFull To Your Work.
|
|
|
|