|
hi,
without deriving a new CRecordset class,how can u make use of databases.
swapna_signsin
|
|
|
|
|
I am not understanding your question. Please clarify. You have one class derived from CDialog . You have another class derived from CRecordset . Correct?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
hi,
I've derived a CRecordset class thru which I made use of Dbases.So now the application should be modal dialog based,so I need to use many dialogs so dbase should be applicable for all the dialogboxes.Now,how do I need it,In class wizard,wht should be base class of Dialog box.This is a dialog based application
swapna_signsin
|
|
|
|
|
swapna_signsin wrote: so I need to use many dialogs so dbase should be applicable for all the dialogboxes.Now,how do I need it,
You could make the CDatabase and CRecordset objects part of the main CDialog -derived class. Then all subsequent dialogs can get access to them by simply calling GetParent() . Make sense?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
hi,
The dialog box class is entirely different from CRecordSet Class.
The Steps to do while doing RecordSet Operations in a Dialog.
step -1 :
Insert a Dialog from [Insert Menu - Resource] from the menu editor from the VC++ Editor. which will create a new Dialog for you.
step -2 :
Give a Class to the Dialog for that you double clik the Dialog and a Message Prompt will appear to you asking the name for the dialog. where you should type a Class Name for the Dialog.
step -3 :
Insert a new Class form [insert Menu - new Class] which will prompt a new class type a new class and derive that class from CRecordSet which will be asking the DataSource and the Table you want to Use. select accordingly and then clik ok of the wizard. Finally a RecordSet Class of what ever you have given a name will be generated.
step -4 :
now you have created a class for Dialog and RecordSet. Include the RecordSet Class header file in the Dialog Class and create an instance of the RecordSet and use all the Database Operations.
this is the approach for normal Database using DSN. another approach is ADO which is very simple.
thanks,
uday.
uday kiran
|
|
|
|
|
Hi,
Thankyou,U 've given me quite a good and detailed explanation which definitely helped me.
Thanx
bye
|
|
|
|
|
I opened a new VC++ project (empty one) and I trying to use the Object class like: Object *ob = new Object() but the compiler doesn't recognize the declaration of Object ,Why? dose I need a include file ?
Thanks Uri
|
|
|
|
|
#include <windows.h>
thus, if you added MFC support to your project at creation, it would have been done automatically. see in the project settings for MFC support.
|
|
|
|
|
Which Object class ?? This class doesn't exist
Is it a class you defined yourself ? If yes, don't forget to include the header file.
BTW, when you have compile errors (or linker errors), post the exact error message. They are much more helpfull than a 'the compiler doesn't recognize the declaration of Object'.
-- modified at 8:12 Wednesday 12th April, 2006
Seing the previous post, maybe you are speaking about CObject from the MFC (and not Object) ?
|
|
|
|
|
|
I think this will remain a secret
|
|
|
|
|
remains me a discussion of yesterday in the lounge
|
|
|
|
|
Which one ? I don't remember...
|
|
|
|
|
sorry, it was on monday
here[^] is the link
|
|
|
|
|
That is soooo true ! And something that is even worse is when you ask the guy for more informations and never get an answer. This is really totally selfish !
Hum, wait, even better: when the guy doesn't answer you but deletes his first message when he got his answer
|
|
|
|
|
|
v2.0 wrote: hey, i'm not selfish...
I don't get you . I was speaking of people who are asking questions and once they have the answer to their questions, they delete their first message. Did you do something like that ?
|
|
|
|
|
yup, you didn't get me...
i said "doh", for such kind of guys...
and i said also "i'm not selfish" myself,, and so delivered you 2 '5' votes
|
|
|
|
|
Ok, it's the morning so my brain needs to wake up
|
|
|
|
|
Cedric Moonen wrote: Ok, it's the morning so my brain needs to wake up
ok, '1' for you :-> hey dude, i'm joking !
|
|
|
|
|
Hi,
some sample code for read data from xls file.
CDatabase database;
CString sSql;
CString Name, Address;
CString sDriver;
CString sDsn;
CString sFile = "c:\\kdr.xls"; // the file name. Could also be something like C:\\Sheets\\WhatDoIKnow.xls
// Clear the contents of the listbox
m_List.ResetContent();
// Retrieve the name of the Excel driver. This is
// necessary because Microsoft tends to use language
// specific names like "Microsoft Excel Driver (*.xls)" versus
// "Microsoft Excel Treiber (*.xls)"
sDriver = GetExcelDriver();
if( sDriver.IsEmpty() )
{
// Blast! We didn´t find that driver!
AfxMessageBox("No Excel ODBC driver found");
return;
}
// Create a pseudo DSN including the name of the Driver and the Excel file
// so we don´t have to have an explicit DSN installed in our ODBC admin
sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriver,sFile);
TRY
{
// Open the database using the former created pseudo DSN
// sSql = "INSERT INTO demo (Name,Address) VALUES ('Nilesh','Pune')";
// database.ExecuteSQL(sSql);
database.Open(NULL,false,false,sDsn);
// Allocate the recordset
CRecordset recset( &database );
// Build the SQL string
// Remember to name a section of data in the Excel sheet using "Insert->Names" to be
// able to work with the data like you would with a table in a "real" database. There
// may be more than one table contained in a worksheet.
sSql = "SELECT Name, Address "
"FROM demo "
"ORDER BY field_1";
// Execute that query (implicitly by opening the recordset)
recset.Open(CRecordset::forwardOnly,sSql);//,CRecordset::readOnly);
// m_List.AddString( Name + " --> "+Address );
// recset.Open(NULL,sSql,NULL);
// Browse the result
// while( !recset.IsEOF() )
// {
// Read the result line
recset.GetFieldValue("field_1",Name);
recset.GetFieldValue("field_2",Address);
// Insert result into the list
// m_List.AddString( Name + " --> "+Address );
// Skip to the next resultline
recset.MoveNext();
// }
// Close the database
database.Close();
}
CATCH(CDBException, e)
{
// A database exception occured. Pop out the details...
AfxMessageBox("Database error: "+e->m_strError);
}
END_CATCH;
}
problem occur after
recset.Open(CRecordset::forwardOnly,sSql);//,CRecordset::readOnly);
it is not enter into condition. go to catch and throw error
Database error : To few parameters expected 2. why this error occur. pls give me where I am wrong in code.
my aim is when I click on Read button, display data from file. kindly give me a reply.
regards
kedar
Girish
Software Developer
|
|
|
|
|
vcforums wrote: sSql = "SELECT Name, Address "
"FROM demo "
"ORDER BY field_1";
I suspect that this is your problem. I see where you selected into the demo table the Name and Address but there is no mention of a "field_1". If the field that is in your SQL select statement does not exist, then you will get that "too few parameters" error. Make sure that all of the fields exist in the database that you are trying to read.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|
|
hi all,
how to acess messages from MSMQ Events when message arrived from source to Destination in OnArrived() function.
thanks,
uday.
uday kiran
|
|
|
|
|
I've got a console project, just console.cpp; stdafx.cpp; stdafx.h
Then something happend to it and breakpoints started to appear randomly in the code after launching it in debug mode.
I've cleaned solution and rebuilded it, useless.
Now I deteleted Debug and Release dirs, deleted *.ncb; *.sln; *.suo files and loaded project again. Useless, launch it in debug and thats it! breakpoints start to appear randomly. Ahhhhh....
9ine
|
|
|
|
|
I have no idea what is wrong with your system - have you ruled out a hardware problem? Are any other applications or your system affected?
Have you run a virus/spyware checker recently?
[I cannot stand people that vote on something without providing feedback when their vote may not be obvious. I cannot imagine any intelligent reason to vote your post a "3"...]
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|