|
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
|
|
|
|
|
Do you just want to know how to read/write data from/to files? From what you've said in your previous posts, I understand that your requirement is to store and retrieve data in an organised manner. If I am right, then use an .inf file, which is meant to store app related data. There are plenty of examples at CP. Click here[^], pick an article and read.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
give me reasonable answer please
gujar
|
|
|
|
|
What is that you did not understand? You can make use of a .inf file to store and retrieve app related data. Use a CFile object and create a .inf file. Then use the following functions to store/retrieve data from the file.
GetPrivateProfileString()
GetPrivateProfileInt()
GetPrivateProfileSection()
GetPrivateProfileSectionNames()
WritePrivatProfileString() ,etc..
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Reasonable means not doing all the work for you. If you want someone else to do your work, then you are being unreasonable.
|
|
|
|
|
MFC makes it easy to use the registry for simple things such as this.
|
|
|
|
|
But the person is very keen about doing it with files and not with registry. That's why I suggested him those API functions to deal with INF files.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Okay.
If however the registry is an option, then both solutions are possible.
|
|
|
|
|
MFC tries to make this easy using the serialization capability of CDocument. Do you know if you are supposed to use that or not use that?
Login name and password are typically stored in the registry. You can use CWinApp::WriteProfileString and CWinApp::GetProfileString to easily store and restore data to/from the registry.
|
|
|
|
|
rajaasif wrote: please can anybody send code:
Oh no, not again!!! i am seeing this line pretty often these days..
vijay.
|
|
|
|
|
I am getting the runtime error: "Debug Assertion Failed" from mfc71d.dll when try to create application class object in another file.
MyApp.h<br />
class CMyApp : public CWinApp<br />
{<br />
public:<br />
---<br />
HRESULT GetCommonDevice(LPDIRECT3DDEVICE9& m_pd3dDevice_REF);<br />
---<br />
}<br />
<br />
<br />
MyWnd.h<br />
#include "MyApp.h"<br />
class CMyWnd : public CWnd<br />
{<br />
DECLARE_DYNAMIC(CMyWnd)<br />
public:<br />
CMyWnd();<br />
void init();<br />
---<br />
}<br />
<br />
MyWnd.cpp<br />
---<br />
void CMyWnd::init()<br />
{<br />
CMyApp c;<br />
HRESULT hr = c.GetCommonDevice(m_pD3dDevice); <-- Here the debug assertion at run time<br />
---<br />
}<br />
}
Any help would be greatly appreciated!
Thanks & Regards,
Suman
|
|
|
|
|
Use like this
HRESULT hr = (afxGetApp())->GetCommonDevice(m_pD3dDevice);
rather than
CMyApp c;
HRESULT hr = c.GetCommonDevice(m_pD3dDevice);
nirmal
|
|
|
|
|
if u want to acess CWinApp use AfxGetApp() .Each application that uses the Microsoft Foundation classes can only contain one object derived from CWinApp
never say die
|
|
|
|
|
rp_suman wrote: CMyApp c;
HRESULT hr = c.GetCommonDevice(m_pD3dDevice); <-- Here the debug assertion at run time
What are you doing ?
Application object is available globally.
You can use AfxGetApp() to access it.
|
|
|
|
|
Thanks for help.
I have tried using AfxGetApp() already but the App classe's functions are not listed by intellisense but only MFC's CWinApp class functions are listed. I am debugging the problem.
Thanks & Regards,
Suman
|
|
|
|