|
I've never done any database project and I dont' know how to start. I saw several article about database using c++.net, ADO.net, VB.net,..etc they really confused me.
if I want to create the sample table using MS Access, how? I read some article on Microsoft.com about ADO is better than Automation MSAccess. But I just don't see any article about how to start or begin, creating a simple table with MS Access.
which language I should use c++, vb, or c#. I'm using .Net
and Can you please guide me how to begin please...
thank you
|
|
|
|
|
There is no 'best' language for a database project; it is more dependant on the target platform.
If you are programming for a web page, then PHP is the thing to choose, but if you're attempting to create desktop software with database access, I suggest dwelving into ODBC and MFC's support for ODBC (CDatabase, CRecordset & CRecordview).
Here's a link to the MSDN Library site for database programming with MFC[^].
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Created a Dialog application last night with Menu, one of the choices in the menu is another dialog window which I created a separated class for. However tried to initialise the dialog, but unable to do so. (Note: that this dialog has a FlexGrid and this is what I'm trying to initialise)
Suggestions much appreciated
Kind Regards
Caoimh
|
|
|
|
|
Please be a little more specific. What do you mean with "tried to initialise the dialog"?
Usually you open a new dialog in a dialog based app like this:
At the top of the file:
#include "MySecondDlg.h" At the place where you want to open the dialog:
CMySecondDlg dlg;
dlg.DoModal(); That's it...
Regards, mYkel
|
|
|
|
|
I've done it exactly as you indicated but what if you want to initialise values in a Grid like FlexGrid or even an edit box?
Kind Regards
Caoimh
|
|
|
|
|
All initialisations of a dialog are usually done in the OnInitDialog() method.
The method OnInitDialog() gets called before a dialog is shown.
So just start the dialog as you have done it already and handle OnInitDialog()
in your CMySecondDlg(). Here's a short example:
MyFirstDlg.cpp:
#include "MySecondDlg.h"
...
CMySeconDlg dlg;
dlg.DoModal() MySecondDlg.cpp:
BOOL CMySecondDlg::OnInitDialog()
{
...
myEditBox = "Just an example..."
UpdateData(FALSE);
} Normally the OnInitDialog() message handler is create by default, so you just have to add your initialisations like above. Otherwise you have to create this message handler by yourself.
Regards, mYkel
|
|
|
|
|
hi all,
i did never care that much about unicode, WCHAR, T_(), UTF-X and all these character-width things. but now someone wants to have an UTF-8-encoded string from my application.
so now i'm sitting here for hours reading FAQs and postings and still haven't found the
<br />
CString::ToUtf8( BYTE *pUtf8String, long &nSize)
function. where is it?
for real: what's the easiest way to just get that CString i have into UTF-8? (my app is compiled without _UNICODE - so the chars in the CString are all 8 bit wide).
tia
:wq
|
|
|
|
|
I belive you are back to Win32 here.
Use MultiByteToWideChar to convert the string, specifying CP_UTF8 as the code page.
Store the result in a WCHAR array and from that point on I think you are without your faitful CString, in .NET there is a CStringW and CStringA that you can explicatly use or a normal CString which is set depending on the _UNICODE define, but not in VC6.
You could always try STL - string and wstring.
|
|
|
|
|
but MultiByteToWideChar() doesn't construct a UTF-8 encoded string, does it? afaik the point in UTF-8 is that characters < 0x7F are still only 8bit wide.
btw: i'm on VS.NET 2003 if that makes any difference.
:wq
|
|
|
|
|
MultiByteToWideChar(CP_ACP, );
WideCharToMultiByte(CP_UTF8, ); The first converts the code page your thread is running on into UTF-16 (2 byte Unicode encoding). This is necessary to get the canonical Unicode values. The second performs the fairly simple transform from UTF-16 to UTF-8.
Of course, if you're sure you'll only ever be using the ASCII character set, you already have UTF-8, since the first 128 characters are a direct map. Since you have an accent in your name, though - ü is ANSI code 252 (and also Unicode U+00FC) - I assume you'll need the proper technique.
|
|
|
|
|
yup thx. i just figured out how to use Wide...()
CStringW str("äö€èéß");
long size = str.GetLength()*6+1;
char *out = new char[size];
if (!WideCharToMultiByte(CP_UTF8,0,str,-1,out,size,NULL,NULL))
{
DWORD err = GetLastError();
}
delete [] out;
*6 is a bit exaggerated, but you never know - memory is cheap nowadays
i'll use that multitowide-function too - thx for your reply. things look way smoother now
:wq
|
|
|
|
|
I testing C++ application:
I install second Win2000.
Made local disk available for both,
but when I change directory in base OS,
disk content in second OS remains not changed.
So question - how to make interact OS-es
through hard disk ?
thanks.
|
|
|
|
|
Hi all,
How do i control the actions(capturing mouse and keyboard events) and disabling some menu items in IE?
Thanks in advance,
AL
|
|
|
|
|
Hi, I have a logging class which contains a <code>static std::map</code> of logfilename to std::ofstream, so that I can ensure every logging object uses the correct stream.
When I first attempt to access the map in any way, by calling <code>insert()</code> or anything else, I get an Access Violation from within STL. Has anybody come across this before, or am I missing something obvious?
My classes are outlined as follows:
<code>class LogThis
{
public:
LogThis(const std::string& logName);
~LogThis();
...
private:
...
static std::map<std::string, LogFileStream> mLogFileStreams;
};</code>
Where LogFileStream is just a simple class with a pointer to an std::ofstream and a reference counter of how many logging objects are using the stream, so I know when I can close the stream and delete the pointer.
The logging class is contained within a static lib and I am using Visual Studio.Net.
Any help would be much appreciated.
Thanks,
Christopher
The bomb lives only as it is falling
|
|
|
|
|
How have you then "declared" this static variable (mLogFileStreams? By that I mean in the CPP for the class, you will have something to initialise the map, like this:
std::map<std::string, LogFileStream> LogThis::mLogFileStreams;
What have you got there?
Try a simple test, change the map to map "simple" types, ie map int-to-int, that way you can pinpoint the problem a bit more to either the LogFileStream class causing the map problems, or the map itself.
|
|
|
|
|
Yes, I initialise it at the top of my cpp file, otherwise it wouldn't compile.
std::map<std::string, LogFileStream> LogThis::mLogFileStreams = std::map<std::string, LogFileStream>();
I also tried just this:
std::map<std::string, LogFileStream> LogThis::mLogFileStreams;
But it didn't seem to make any difference. Anyway, I shall experiment with some primitive types and report back.
The bomb lives only as it is falling
|
|
|
|
|
<small><b>simcoe23 wrote:</b></small>
<i>Yes, I initialise it at the top of my cpp file, otherwise it wouldn't compile.</i>
Note is says "how have you" not "have you"
Anyway, std::map definatly do work as static memebers, so it's probably something with your other class. For instance this works without problem
typedef map<int, int> MYMAP;
class A
{
public:
static MYMAP aMap;
};
MYMAP A::aMap;
int main(int argc, char* argv[])
{
A aa;
aa.aMap.insert(MYMAP::value_type(3, 3));
return 0;
}
|
|
|
|
|
Hi there, sorry I didn't notice the "how have you" .
I just tried with a std::map<int,int> and exactly the same thing happens.
The map.insert code is being called in the constructor of my main class, might that be a problem? Basically you create this logging object by passing a filename into the constructor, it checks if the file stream is already open, if not it opens a new stream and stores it in this static map using the filename as a key.
The other thing to mention is that the logging object which is being constructed is a global - I declare it using 'extern' at the bottom of my header file, which may or may not be the right thing to do.
The bomb lives only as it is falling
|
|
|
|
|
Yes - Maybe
The important bit is "logging object which is being constructed is a global " does this mean that the class that is using the map, which is static, is also being declared as global? Or does it mean the logging class which uses the map is declared global, then you have another "main" class that uses the logging one, which isn't global?
When your app starts up, the C runtime libray will init all your static and global members and doesn't do these in any perticualr order - when your constructor calls insert on the map, it's likley that the map hasn't been created yet.
Comment out the line that insert's into the map into the ctor, put a break point in your classes ctor, when it gets hit, check the call stack and go back to the _inititem functions - this is the CRT calling the ctors for all your global variables. Step back out of your ctor to this loop, and you should see that the loop then go into the ctor for the map - IE the map is being created after your ctor is being called, and you get a AV.
You could have a Init() method on your logging object or something, there are a few soultions to this problem really.
|
|
|
|
|
Cool, thanks. Changed it so that the stream is only opened the first time you write to it, and that seems to work. Now of course I am having the same problem when the object destructs, but at least i know what's causing it.
Thanks for your time.
The bomb lives only as it is falling
|
|
|
|
|
No problem
Nowt to do today at work anyway
|
|
|
|
|
hello,
i need to adjust the access rights to the local cd drives installed in the computer. for this i'm retrieving kernel object security and adjust the dacl by adding a grant access with the necessary rights for the users group.
this worked perfectly in the past, the settings are applied and the security changes affected the system as expected.
but now the settings are removed after restarting the computer. all functions return a successful condition and the settings are changed as long as the computer is not restarted.
does this have to do with w2k sp3 ? we were using sp1 previously and it was working there.
does anyone has a clue what i can check or where i can search ?
many thanks in advance
enrico
|
|
|
|
|
first: sp4 is the latest!
2nd: why do u need to adjust the access rights for your cd drive?
Don't try it, just do it!
|
|
|
|
|
i need to adjust the security settings to be able to record cds with the nero software even if i do not have admin rights. nero is providing a tool to adjust the burn rights, but i tried to recreate the functionality to include it in another application, so i do not need the nero burn rights tool and can automate the process of changing the security settings.
and this was working perfectly, but in the meantime the behaviour changed. i cannot say, if it is related to the service pack, but i have no idea what i can check. adjusting the security with the nero utility is still working by the way.
|
|
|
|
|
Hello,
I am trying to do a object oriented multithreaded program with MFC.
In order to do that, I have a class CToto whose contructor creates 2 threads with AfxBeginThread. As an argument to AfxBeginThread I pass the this pointer.
CToto::CToto()<br />
{<br />
/...other inits here.../<br />
fastThread = AfxBeginThread((AFX_THREADPROC)ObjectFastThreadRoutine, this);<br />
slowThread = AfxBeginThread((AFX_THREADPROC)ObjectSlowThreadRoutine, this);<br />
}
(The CToto instance is created on the heap with the new operator in the OnInitDialog of a CDialog class.)
The thread proc are as follow:
UINT ObjectFastThreadRoutine(CToto* lpParam) <br />
{ <br />
lpParam->FastThread();<br />
return 0;<br />
}
UINT ObjectSlowThreadRoutine(CToto* lpParam) <br />
{ <br />
lpParam->SlowThread();<br />
return 0;<br />
}
I have therefore two thread running in two members functions of the CToto class. The goal of this approach is to acces to the variables of this class with both threads.
To be thread safe, I read and write in the member variables that I want to share with functions which are protected with CCriticalSection objects, here is one of those functions used to write to the positionMeasured member variable of CToto:
void CToto::SetPosition(double *pos)<br />
{<br />
CSingleLock singleLock(critSectionPosition);
singleLock.Lock();<br />
<br />
for(int i=0; i<4; i++)<br />
{<br />
positionMeasured[i] = pos[i];<br />
}<br />
<br />
singleLock.Unlock();<br />
}
I have three differents member variables such as positionMeasured that are protected like that. All those three variables have Get and Set functions to read and write.
My problem occurs when the SlowThread tries to access to the SetPosition function. I have a debug assertion failed at the CSingleLock singleLock(critSectionPosition); line. The assertion is the following:
CSingleLock::CSingleLock(CSyncObject* pObject, BOOL bInitialLock)<br />
{<br />
ASSERT(pObject != NULL);<br />
----> ASSERT(pObject->IsKindOf(RUNTIME_CLASS(CSyncObject)));<br />
<br />
m_pObject = pObject;<br />
m_hObject = pObject->m_hObject;<br />
m_bAcquired = FALSE;<br />
<br />
if (bInitialLock)<br />
Lock();<br />
}<br />
BOOL CObject::IsKindOf(const CRuntimeClass* pClass) const<br />
{<br />
ASSERT(this != NULL);<br />
------> ASSERT(AfxIsValidAddress(this, sizeof(CObject)));<br />
<br />
CRuntimeClass* pClassThis = GetRuntimeClass();<br />
return pClassThis->IsDerivedFrom(pClass);<br />
}
I really don't know what to do. I am not an expert in multithreading and maybe (sure) I am doing something false with memory access and memory zone of threads. So if anybody can help me on how to solve this problem or can propose me another program structure for one class with shared ressources and two threads accesing them concurently (those threads must be able to access the private members of the class if possible)
Thank a lot for your answers.
Regards
TV
|
|
|
|
|