|
I have been searching the net for a simple database application using visual c++. I want somebody to help me with how to develop just a small application for entering records, deleting, updating and searching using visual c++ and ms sql server 2005. Even if it can be for one record, I can extend that to whatever the number of columns I have in my database. I have been developing some but all in vain. Nothing seems to work.
Please!
phokojoe
|
|
|
|
|
phokojoe wrote: Nothing seems to work
What have you tried that didn't work? Is the problem UI related? Database access related?
phokojoe wrote: how to develop just a small application for entering records, deleting, updating and searching
Maybe break that down into managable chunks and show some sample code that you're having trouble
with and we can hopefully help you out.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
You need to look into using the CDatabase[^] class. Below is come code to read some records from an Access DB which can be easily modified for MS SQL Server. Using those two classes you can update, read, create, etc. I believe I got much of this original code from CP but I cannot for the life of me remember where so I can't credit the author.
CDatabase m_database;
CRecordset *m_recset;
bool Read()
{
CString SqlString;
CString sVideoName, sFileLocationRelative;
CString sDriver = "MICROSOFT ACCESS DRIVER (*.mdb)";
CString sDsn;
CString sFile = "Database\\VideoDB2.mdb";
sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriver,sFile);
TRY
{
m_database.Open(NULL,false,false,sDsn);
m_recset = new CRecordset( &m_database );
SqlString = "SELECT * FROM VIDEOS";
m_recset->Open(CRecordset::forwardOnly,SqlString,CRecordset::readOnly);
while( !m_recset->IsEOF() )
{
VideoRecord tVideo;
CDBVariant vID;
CDBVariant vRunTime;
CDBVariant vName;
CDBVariant vImagePath;
CDBVariant vVideoPath;
CDBVariant vDescription;
m_recset->GetFieldValue("VIDEO_ID", vID);
m_recset->GetFieldValue("VIDEO_RUN_TIME", vRunTime);
m_recset->GetFieldValue("VIDEO_NAME", vName);
m_recset->GetFieldValue("VIDEO_IMAGE_PATH",vImagePath);
m_recset->GetFieldValue("VIDEO_PATH", vVideoPath);
m_recset->GetFieldValue("VIDEO_DESCRIPTION",vDescription);
tVideo.iVideoID = vID.m_iVal;
tVideo.lRunTime = vRunTime.m_lVal;
tVideo.stVideoName = *vName.m_pstring;
tVideo.stImagePath = *vImagePath.m_pstring;
tVideo.stVideoPath = *vVideoPath.m_pstring;
tVideo.stDescription = *vDescription.m_pstring;
m_vVideos.push_back(tVideo);
m_recset->MoveNext();
}
m_recset->Close();
}
CATCH(CDBException, e)
{
AfxMessageBox("Database error: "+e->m_strError);
return false;
}
END_CATCH;
return true;
}
By the way, that VideoRecord structure was just a part of my program, so you can ignore it.
Hope this is helpful,
Dustin
|
|
|
|
|
I have an view derived from CScrollView and I make the image fit to width so my horizontal scrollbar disappears. Problem is, I need that scrollbar to remain visible so user can add additional space to the image by clicking the scroll buttons.
I would like to continue to use CScrollView as it still saves a tad bit amount of work and code compared to CView but I'm not having much luck getting the scrollbars to remain visible.
I've tried adding some addtional padding space around the image but it has an undesireable effect and I'm trying to mimic the functionality of some commercial products that do not appear to use padding around the image.
Does anyone know how to force the scrollbars in CScrollView to remain visible and enabled?
|
|
|
|
|
bob16972 wrote: Does anyone know how to force the scrollbars in CScrollView to remain visible and enabled?
Try calling SetScrollSizes() in OnInitialUpdate() after the call to the base class. Add the amount of additional space you need.
|
|
|
|
|
Unfortunately, I do that already dynamically as the view size changes (use SetScrollSizes() that is) and I tried adding some padding to force the scroll bars to remain visilbe but the effect would be somewhat confusing to the user as it is a fit to width application.
Some commercial products allow the user to temporarily scroll beyond the image edge and add some drawing primitive or object and recalculate the page size and readjust the scroll sizes on the next view resize or scroll bar action to remove the excess space that wasn't needed. They leave the horizontal scroll bar visible but the thumb is full size (or darn near close to it). VC++ 6.0 kinda does this when you scroll past the bottom of a document.
Thanks for taking the time to give me some advice. When it appears that I might be creating more work than necessary, I like to get some professional feedback as a sanity check. Unfortunatley, it looks like I'm going to have to derive from CView at this point.
Thanks again and take care.
|
|
|
|
|
I'm not sure how much you're going to have to fight the MFC code to do this.
Take a look at the source (viewscrl.cpp), particularly all the calls to SetScrollInfo() and
SetScrollRange().
There's the SIF_DISABLENOSCROLL flag for SetScrollInfo() but while letting the bar remain shown,
it will be disabled which isn't what you need.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I'm betting I'm going to have to revert back to deriving from CView.
I guess I'll earn my pay today.
Thanks for taking the time to share your thoughts and advice.
|
|
|
|
|
Why the wizard dont give a destructor for the CDialog derived class.
Is there a special reason?
Thnak you.
KIRAN PINJARLA
|
|
|
|
|
kiran.pinjarla wrote: Why the wizard dont give a destructor for the CDialog derived class.
Its not always necessary. But if you need it, just add it.
|
|
|
|
|
Thak you.
I just wanted that.
KIRAN PINJARLA
|
|
|
|
|
Hi,
As all the destructors. The reason is to free the possible resources that have to be removed to avoid memory leaks or trash in memory. Specially the ones you are using during the whole life-time of the Dialog itself.
The only problem with that is that you can not free "graphical" resources because you don't have the parent window (the dialog) anymore, so the m_hWnd is NULL and is impossible to access them. In this point is better to use the WM_CLOSE because it is called just before destroying the window/dialog.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
how to get a ascii value of address in ip address control
|
|
|
|
|
prathuraj wrote: how to get a ascii value of address in ip address control
Do you mean the textual representation of the IP address?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i want to get ascii value because i cant differenciate (. . . .) and (0.0.0.0) in ipaddress control.I want to check each field in ipaddress control with space or zero.how to do that
I read the value from ipaddress control by Getdlgitem(id)->getWindowtext(cstring)
|
|
|
|
|
Have you ignored the GetAddress() method? In addition to getting the actual value from the control, it returns the number of non-blank fields.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
how to use getaddress function for dynamic one
|
|
|
|
|
prathuraj wrote: ...for dynamic one
You created a "SysIPAddress32" control dynamically?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
no,I used the class CIPAddressCtrl
|
|
|
|
|
prathuraj wrote: I used the class CIPAddressCtrl
Which has no bearing on whether you created the underlying control at design time or at run time (i.e., dynamic).
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I've written a little web crawler in VC++, which grabs financial indices and quotes from different websites and shows them.
If the sources are plain html, everything is fine.
Now I've got a website which shows the quotes dynamically (http://www.forexpf.ru/quote_show.php[^]).
IMHO there are 2 ways to get the information extracted:
1. grab the page as image, make OCR and extract the info
2. load the page into a browser control to build the content, copy the content text (into clipboard) and extract information
#1 works in general, but ocr actually isn't accurate enough.
#2: Are there any examples to show the handling of clipboard?
On the other hand: Use of clipboard wouldn't be my first choice because the grab process is repeated automatically in background and with use of clipboard other applications running would be influenced. Are there any other ideas to solve the problem?
TIA
M.
|
|
|
|
|
Mathefreak wrote: 2. load the page into a browser control to build the content, copy the content text (into clipboard) and extract information
Try using IWebBrowser2, IHTMLDocument, IHTMLElement , and related interfaces.
Regards,
Paresh.
|
|
|
|
|
Mathefreak wrote: If the sources are plain html, everything is fine.
Now I've got a website which shows the quotes dynamically (http://www.forexpf.ru/quote_show.php[^]).
But the tables are still HTML. Unless I am not understanding, isn't row #3 of the upper-left table always "NASD Comp?" Or are you saying that the first column in each table continually changes?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
By "dynamically", I assume you mean you can't rely on the order of information? If so, you could scrape tuples (eg: "NASD100=1888.08") instead of assuming the location of specific entries in the table.
Btw, I wrote this[^] in order to build this[^].
/ravi
|
|
|
|
|
The only things which changes in the resulting webpage are the quote.
My aim is to get the quote for DAX (7th row in upper left table).
Are there any example to use the IWebBrowser2 interface to get the information.
TIA M.
|
|
|
|