Populate MFC Datagrid control from SQL Server


I am using the following code to transfer data from a SQL database to a MFC 
Datagrid control

CCommand<CDynamicAccessor, CRowset> dbCommand;

	        Recordset20Ptr spRs;
	        ADORecordsetConstructionPtr spADOsCt;

            CDBPropSet propset(DBPROPSET_ROWSET);            
            propset.AddProperty(DBPROP_CLIENTCURSOR, true);
            propset.AddProperty(DBPROP_IRowsetChange, true);
            propset.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_CHANGE | 

            CString sCommand;
            sCommand.Format("SELECT * FROM NewEvents");
	   HRESULT hr = 

         hr = dbCommand.Open(&propset, NULL, true);

	 hr = spRs.CreateInstance(__uuidof(Recordset));

         hr = spRs->QueryInterface(__uuidof(ADORecordsetConstruction), (void 


	 hr = spADOsCt->put_Rowset(dbCommand.m_spRowset);

            // populate DataGrid by assigning it a Recordset object.
	        m_ctlDataGrid.SetRefDataSource( (LPUNKNOWN) spRs );
	 catch (_com_error &e)

This code works fine. What i would like to do is to be able to populate the 
Datagrid with another recordeset that i have built myself.  

i.e i want datagrid to be able to show data based on the previous query, 
such as the number of records returned and various other data.

When the user selects a summary button on the dialog the datagrid will be 
cleared of the initial data and replaced with this summary data. This summary 
data will be built up by traversing the recordset above,spRS, then building 
another recordset with the summary results before putting this new summary 
recordset into the datagrid.

Can anyone tell me how i could traverse the above recordset and create a new 
recordset,not from database but by doing some operations on the original 
recordset e.g perhaps doing a sum of one column. I will then populate the 
datagrid from this new, user defined recordset.

Thnaks In Advance
macca (52)
5/24/2005 2:26:14 PM
vc.mfc 33608 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 0


Similar Artilces:

Tooltips don't work for CEdit controls
Hi, I'm using VC++ in VStudio 2005. Inside my dialog of CDialog base type, I'm dynamically (programmatically) creating several child edit controls of my own type (CSendchk) based on CEdit. These edit controls look and function perfectly within the parent dialog. I would like to display a tooltip when mouse hovers over any of those edit controls. So, as the help reference guide suggests, I added a call to EnableToolTips(TRUE) inside my InitDialog() method and hook the notification with my override CSendchk:OnToolTipNotify(). As expected, I do receive the notification for my O...

Remove old failed server from ADSI
Hi, I actually work with an 2K3 R2 server SERVER2. This server is the only DC of the domain. But I found with frsdiag and ADSI old records about SERVER1 that no longer exists. This cause DFRS issue and Exchange pb. I found a solution for the DFRS with adsutil clean metadata. But how to remove olds records from ADSI in the following path : CN=Servers,CN=Premier groupe administratif,CN=Administrative Groups,CN=DOMAIN NAME,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=DOMAIN NAME,DC=com Thanks in advance. -- Julien Demarey This is more an AD issue rather than Exch...

Populating Excel from CSV
Hello all, I need to know how to populate an Excel template with data from a external CSV file. Let's say I have this nice pretty colourful templat that is far more pleasing to the eye than the usual chunk of importe CSV data, what are some methods to populate it with data from a CS file?? Any ideas or suggestions or redirections would be much appreciated. Thanks in advance : -- AJMorgan59 ----------------------------------------------------------------------- AJMorgan591's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2777 View this thread: http://www.ex...

Windows 2003 server SetForegroundWindow|BringWindowToTop|SetWindow
Hi all, I'm trying to use this functions (SetForegroundWindow|BringWindowToTop|SetWindowPos) on Windows 2003 server, but it is working when I have a Administrator level and when I try the sameprogam with the operator level I have an exception like <Impossible to run this information from the remote pc>. I tryed the same program on Window XP with the operator level and it is working. Somebody knows why ? I'm looking forward to receiving an answer soon possible. BR lolo An exception sounds surprising; none of those APIs are specified as throwing an exception. You would...

Sequence Not populated for the MO Numbers during Data Collection
When data collection is done for the MO Numbers by using the Data Collection Window under Manufaturing, the Sequnce look up does not show the whole list, it only shows NOTES, for the user to select and enter the necessary data. why does this happen in the case of some MO Numbers and in the others it shows all the sequnces as NOTES,MAKE READY, PRESS RUN, WASH UP, MAINTENANCE, REPAIRS, REWIND/INSPECTION, etc. Any information would be much appreciated -- Thanks AshaM It should show all of the router steps. Are some of your steps possibly marked to backflush labor? These steps would not...

SendAs for "Exchange Domain Servers" and "Exchange Enterprise Servers" denied
Hi all, I'm having problems with SMTP with all my exchange servers (4) under the same organization. The Event IDs are 7010 and 7004. I look them up and they are caused by the impossibility to authenticate between servers. I've made focus on the article 843106 http://support.microsoft.com/default.aspx?scid=kb;en-us;843106&sd=ee there, this paragraph call my attention: If Integrated Windows Authentication is enabled, but the events persist, the sending server in the 7004 event or in the 7010 event may lack or be denied the SendAs right on the receiving server. If the sen...

how to replace the "new" and "delete" operator funtion define in mfc.
I am trying to overload the global new and delelte operator function in order to use my own memory allocation mechanism.Every time i do it smoothly until i get to a MFC project. The problem is that there are already a set of new and delete operator function defined in afxmem.cpp of MFC. While i'm trying to replace them with my own,the new operator call the MFC's operator new function and call my operator delete function.This is a surelost. How can i replace them completely? Booker, Best regards. It is strongly recommended that you do not overload operator new/delete....

MFC Support in DLL's
I realize this is probably an old and often repeated question, but I have been unable to find any articles that have been able to help me. I have a DLL written in plain win32 that I want to add MFC support to. I'm having trouble with the DllMain function. I've tried just removing the entire DllMain function, yet I'm still getting the compiler error that DllMain is already defined. What Do I need to add to make my DLL support MFC? Thanks in advance, ed "ed" <ed@discussions.microsoft.com> wrote in message news:03A4326E-E360-4FAF-B6DF-31D0063DC05A@microsoft....

GP7 (soon to be GP9) and shared SQL server with instances
I am considering restructuring our server topology to accomidate new applications coming into the mix and with that I am thinking of assembling a single SQL 2005 server with 2 or more named instances to accomidate all of our database needs. The server is a Xeon 2xDuoCore 2.8, 4GB, and a Raid 1 (0,1) / Raid 5 (2, 3, 4) hard drive array setup. Are there performance concerns I need to be made aware of that would make me continue the implementation of a dedicated Great Plains server? I have SQL 2000, GP7, a 3rd party add on (Agora), and IIS running some Web Services tied into the database....

substitution operator new & delete provided by MFC?
I tried another memory tracer provided by http://www.fluidstudios.com/, which is called MMGR. Without MFC, MMGR works fine. However, programs using MFC cannot be built because MMGR has some operator new() and delete() functions, which are already defined in MFC library. How can I substitute MFC memory operators to MMGR memory operators? Please reply. Thanks in advance. Bae,Hyun-jik Search your MSDN for "operator new" and read the C/C++ location topics. -- ============ Frank Hickman Microsoft MVP NobleSoft, Inc. ============ Replace the _nosp@m_ with @ to reply. "Ba...

Is it a SQL 2008 or VB 2008 problem? I don't know
Hello, I know I ask this question in early December. I thought I had solved my problem but it is always present. I have created an application with Visual Basic2005 Standard Edition 2 years ago. The application imports CSV files in the database. The application is connecting to the database that I made it with SQL Server 2005. This is the connection string: Data Source=XXX; Initial Catalog=YYY; Integrated Security=SSPI; Pooling=true; The application uses the TransactionScope class this way with no problem: Using Scope As New Transactions.TransactionScope(Transactions.Tr...

Using Alt-key in MFC app
I am creating a cad-program which must simulate the user interface of another program. This means that I need to be able to use Alt-key combinations, like alt-leftmouse and mousemove and such. Default key handling forces the alt key to be used with menu only. Is there a way to work around this safely? Yours, Morten Aune Lyrstad Never mind; got it! Just needed to find GetAsyncKeyState(VK_MENU)! Use GetKeyState instead. "Morten Aune Lyrstad" <too@much.spam> wrote in message news:fBgHc.13$Rb.7643@juliett.dax.net... > Never mind; got it! Just needed to find GetAsyncKeySt...

Import data from Access to SQL
Hello everyone. I have an instance of SQL Server 2008 Express on my PC, I have need to export tables from Access 2007 to SQL. I did successfully migrate (table access with unique ID field primary key) with SQL Server Migration Assistant for Access 2008, I rechecking the tables in SQL and it's all ok. Linking tables in Access. I have saved import (from text files) that work without problems with Access tables, when I go to do one of these imports, at some point the message "Unable to register changes. The entered value violates the settings for the table or the list...

Controling space when exporting EXCEL to text.
We have a program that reads files in a fixed format style of FORTRAN. 8 characters per column of data with no delimiter. I want to export a text file from EXCEL such that each column is limited to 8 characters, that it will stuff blanks as fillers. In somecase it will be a fixed number (i.e. 1.2) and other it will be an exponent (i.e. 210E09) Basically, I need to control the text output of Excel like the good old FORTRAN days. I found that when I use this technique, it goes a little smoother if I choose a nice non-proportional font (I use Courier New) so I can see how things look). But ...

remote server returned an error: (403) Forbidden
When i am trying to install CRM 3.0 on SBS 2003 i got the following error Error accessing URL http://VSERVER: The remote server returned an error: (403) Forbidden. HTTP Error 403.6 - Forbidden: IP address of the client has been rejected. any postive reply please Thanks Shakil Khan Your IIS web-site is most likely configured to only accept requests from a specific range of IP-addresses. Your computer's IP is not within that range. "Internet Protocol (IP) addresses are a useful way to define access permissions. An IP address is a unique number that identifies a computer on ...

Autoplay for Pictures Not Populated
I inserted my XD card in to my card reader today and the autoplay pop up window asking what I wanted Windows to do was blank. For Video, Music and Mixed content the options are there but not for Pictures - it is just blank. I have tried running autofix.exe but this has not fixed it. Any ideas? Is this a Microsoft problem or has something else caused this? It worked fine until today. Thanks. Peachypumpkin wrote: > I inserted my XD card in to my card reader today and the autoplay > pop up window asking what I wanted Windows to do was blank. For > Video, Music and Mi...

CRM 3.0 Upgrade Advisor
HI all, when i running Upgrade Advisor, i face the problem "Duplicate SQL Server SPN was found" how can i solve the problem? Any help would be appriecate regards, NG when you setup crm it will take you through an environment diagnostic wizard...when you get an issue listed you can click on help which should give you steps to resolve it. You might be able to find the duplicate using the ldp.exe tool ========================= John O'Donnell Microsoft CRM MVP http://www.microsoft.com/businesssolutions/crm/community/microsoft_crm_community.mspx "Ng" <Ng@dis...

opening ie from a MFC app
I've written a small application that implements a taskbar icon. When the user double clicks on the icon, I would like to send a system request to open up a specific url. This is analagous to the user going to the start menu and choosing "Run..." and typing in the full URL (http://www.microsoft.com for example). I already have a handler made but I have no idea what to call to send this run command to the shell. Can anyone offer me advice? neo, > menu and choosing "Run..." and typing in the full URL > (http://www.microsoft.com for example). I already have a h...

hi i am working in VC++. I have automated power point from VC++ .I could save the ppt files to jpg. But the jpg files are named slide1, slide 2, slide3 etc. I want them to named with slide title. From the power point news group i got some VB code. But I couldn't find the appropriate function for oSlide.Shapes.Title.TextFrame.TextRange.Text in VC++. priya ...

CRM on Small Business Server 2003
Has anybody had problems with CRM installed on SBS 2K3 with regards to Sharepoint services loosing the SBS "companyweb" Matt Hi, Please check chapter 15 in the Implementation Guide how to setup CRM on a SBS server. More specially page 249 which gives more details about this particular topic. -- Olivier Schmitt Microsoft Business Solutions Support Ce message est fourni en l'�tat, sans garantie d'aucune sorte, et ne vous conf�re aucun droit. Vous assumez tous les risques li�s � son utilisation. "Mat" <anonymous@discussions.microsoft.com> wrote in message...

how do populate empty cells with the contents of populated cells .
I have this worksheet problem. The work sheet is thousands of rows long. One of my columns has cells not populated. I would like to get any empty cell in this column to populate itself with the contents of the next populated cell below it? Kind of a "find and replace" action where by an empty cell says to it self;"I'm going fill myself in with the next thing I find below me" I would greatly appreciate if someone can relate how to do this. Thanks Jim, Select the column, use Edit | Go To... Special , Blanks, OK. Then type an equal sign, press the down arrow...

Problem Publishing to Server
I'm using FP2000 and am having problems publishing changes made on my computer When choosing the "Publish" command, I enter in the website address and then get the dialog box "Name and Password required". I enter the user name and password for my hosted site and this is not accepted. Error message reads "This operation requires author permission for www.(website name).80" Any ideas on how to resolve this issue? I have an urgent upload which needs to be made. Thanks in advance for your help!!! I would recommend checking with your web ho...

Error during CRM Dynamics install with Reporting Services Server
I have installed a test server with SBS 2003 R2 recently and want to add CRM Dynamics. The install fails during the custom install when specifying the Reporting Sevices Server URL. I can't seem to get the sysntax or the true address right. What is the address of the existing Reporting services? Where should I look to find it and what is the valid url address? Any help will be greatly appreciated. Regards, Martin Further info: When I look at SBS Monitoring and Reporting in server managment, I see that I have 5 critical errors in the application log. The event ID's are 107, 17204,...

Server 2003 SBS dies randomly
I have a client with Server 2003 SBS on a Dell PowerEdge SC440. Every once in a while, the server "stops." This seems to happen randomly. I will describe the latest occasion in detail - previous occurrences exhibit a similar chain of events. Other background details: service pack 2 is installed; this is the only server on the network - Backup Exec, Exchange, everything is all on the one server; I installed this OS in March 2008, and this issue has pretty much plagued the server its whole life. At 12:00:18 AM on 5/2, Backup Exec reported that it couldn't log into ...

Tip if Release version works with dynamic MFC dll but not with static MFC
It took me some time to figure this out. My print preview worked when compiling using dynamic MFC libraries, but not in static MFC. I fixed it under the Properties-Resources page. The first field is Preprocesor Definitions. If you created your Application with MFC as Dynamic DLL, there is a definition there called "_AFXDLL". You have to delete it. ...