|
|
Is it possible to create a single device using CreateDevice() function and share in multiple views?
Thanks & Regards,
Suman
|
|
|
|
|
What does CreateDevice() do?
To share data in multiple views, you can store it in document class.
From view class, you can use GetDocument to get document class's pointer and use it's data.
|
|
|
|
|
Thanks.
It creates a device to represent display adapter.
I will try and let you know tomorrow.
Thanks & Regards,
Suman
|
|
|
|
|
It seems we cannot use the single device returned by CreateDevice() in more than one view. Because Create device takes the HWND handle of the view.
Thanks & Regards,
Suman
|
|
|
|
|
rp_suman wrote: CreateDevice()
Is it a DirectX API ?
|
|
|
|
|
Yes it is DirectX API.
Thanks & Regards,
Suman
|
|
|
|
|
Environment: VC 6.0 sp5, MFC, Access97/2000 database, W2000/XP pro.
I have upgraded my app to run msjet4.0 as described by Microsoft when using VC6.0 and MFC in shared DLL:
AfxGetModuleState()->m_dwVersion = 0x0601;
Thats easy!
But, when I start a thread (AfxBeginThread/user or worker), doing some Dao-interface, I get problems:
When I construct a CDaoDatabase and open it from within the InitInstance of the CWinThread, I get:
"First-chance exception in Test2.exe (DAO360.DLL): 0xC0000005: Access Violation."
If I do the same in the constructor of the CWinThread, there's no errors!
Running the dao-interface in a MDI og SDI app, works fine.
Going back to msjet3.0 and access97 target database, works fine. I have searched the web for error reports like this, but it seems that I'm completly alone to have this problem...!
Does anybody have a clue or an idea to solve this problem?
In advance, thanks.
PS! I'm stucked with dao for a little more time - I know, ADO would be the answer...;)
Code example:
CDaoDatabase MyDBS;<br />
MyDBS.Open("C:\\Au2PC\\Database\\Au2PC.mdb");<br />
TRACE( "Database engine ver=[%s]\n", MyDBS.GetVersion());<br />
CDaoRecordset rsMedd(&MyDBS);<br />
rsMedd.Open(dbOpenDynaset, CString("SELECT * FROM MeddUd"));<br />
Anders
|
|
|
|
|
Since it works in an MDI/SDI app, but not from the thread's InitInstance(), I would guess (without looking at the MFC source at this point) that it's related to running a separate thread.
It working in the constructor kind of confirms this, since the object is most likely being constructed (and hence the ctor executes) in the context of the original thread, whereas InitInstance() is run in the new thread.
Obvious stuff;
1. Have you used any of the CDao* classes in the first thread? MFC keeps state information on OLE and DAO which for the new thread might be wrong/misleading.
2. Have you called AfxOleInit() or CoInitialize() in your new thread's InitInstance()?
Steve S
Developer for hire
|
|
|
|
|
Hi Steve. Thanks for your reply - unfortunately, none of your suggestions worked. I can get it to work if I declare my CDaoDatabase and CDaoRecordset as pointers in the WinThread class and allocate them in InitInstance()! Then, when I start another thread with same database construction, it fails again.
Now I have my database interface running only in the main thread (a CDialog based class) The workerthreads calls databasefunctions using the SendMessageTimeout(..) function - a messagehandler in the CDialogbased class handles the requests and return the result. It's a bit clumsy, but it works!! Fortunately, the number of operations on the database is limited, so it's easy done.
I can't figure out what the trick is to get it running directly from the threads. The upgrade from msjet3.5 to msjet4.0 hasn't been that easy!
Anders (still hanging around VC6)
|
|
|
|
|
I confess, at this point, that I don't make much use of CDao* classes these days. I still use (well, the people I contract to do) VC++6, but I tend to use the ATL OLEDB classes for data access.
In your original, were you making any CDao* calls (including object construction) in the main thread? If I have time, I might dig a bit deeper into what's happening, so a look at your original InitInstance() might help me.
Steve S
Developer for hire
|
|
|
|
|
i am trying to use stored procedure to store data in my dtabse getting from remote server....but i dont know from where to start...
i have done ole db connection to database with the help of ATL consumer wizard....now how to proced further...can anybody help me....
|
|
|
|
|
You need to write the stored procedure in your database. Then test it from your app. Here[^] is an example. Googling will give you plenty of results to start with.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
o yes stored procedure are wrriten in dtabase...now i am looking for how to use them on my project in vc++...should i need to use some classes or what....
|
|
|
|
|
You can use the CDatabase class to interact with databases using ODBC. If you are using DAO, then you can use CDaoDatabase class.
PS: Are you looking for the ExecuteSQL keyword?
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
I am not using odbc but i am using OleDb connection for sql server....any idea
|
|
|
|
|
No matter what methodology you adopt to connect to a database. SQL is going to remain the same. I assume you're able to connect to your database from your app. Have a look at this sample[^] which demonstrates how to call a stored procedure from c++.
Also give a chance[^] to google.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
please can anybody send code:
this is the task:
You have to make a database of student’s academic record. Make the database using file (or files). The files should contain information about a student. You have to make a class Student that contains the following member variables.
Student name (CString).
Roll number (that will act the key to identify student) (long).
Batch (int).
Session (CString).
Courses registered (Array of CStrings).
Course GPA (Array of floats).
Semester GPA ( to be calculated from course GPA) (Array of floats).
CGPA (float)
(30)
Make a user friendly interface using MFC that first asks for user name and password from user to identify him/her as an administrator. When the user is verified, open another dialogue that shows options for the following operations to be performed on student data.
Insert record. (15)
View Records (15)
o All records
o View all records of a specific batch.
o Search by student Roll number.
Update record. (10)
Delete record. (10)
Calculate CGPA of student. (10)
Add user. (05)
Change user. (05)
The data should be saved in files for further use.
Plz send me code:
gujar
|
|
|
|
|
|
i have tried, but there are some problems one is that:
How to save the login name and password in the files(streams), i have tried it too but when i type user name and password to login it does not recongnize the name and password; i think i have problem in writing in and reading from the file.plz help me.
gujar
|
|
|
|
|
rajaasif wrote: i have tried, but there are some problems one is that:
How to save the login name and password in the files(streams), i have tried it too but when i type user name and password to login it does not recongnize the name and password; i think i have problem in writing in and reading from the file.plz help me.
The essence of kakan's post says that you need to ask precise questions here. That way people here would be in a better way to help you. Atleast try asking one after another qeustion. You can use the CFile class to do file handling/serialization in MFC. If you need to store your application related data, then you can use the registry for it. There are other options like using an XML file or the classic .inf file.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Thanks for giving an answer to rajaasif. I'm at work and have work to do, so I can't find the time right now.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
My pleasure
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
The easiest way to write and read from a file that has your application related information would be using an .inf file. Use the GetPrivateProfileString() , etc functions for that.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
please can anybody give me example code for writing and reading data in streams(files).
gujar
|
|
|
|