|
Hi All,
I have a problem with disconnected recordsets.I ahve a component.One if it's function will get all the Records in a Database.I am passing the Recordset pointer from the server to the Client.I am using disconnected recordsets for this.
I can see that at the server side I am getting the Recordset
pointer.But, I could not get this pointer on the client side.
the function has the protoype
STDMETHODIMP GetAllElements([out]IUnknown **ppRecordset);
I could get the Recordset pointer at the server side, but could not pass it to client.I am using Client side cursor(adUseClient) and standard Marshaling.
what could be the problem .
Thanx in advance for the help.
Regards,
yamini
|
|
|
|
|
Hi,
What DB are you using? I got similar problem with ACCESS Database, But an attempt with SQL Server database was successful.
regards
Mangesh Sardesai.
|
|
|
|
|
Hi,
I am using MS Access DB for maintaining Records.I am using the SQL
Query for getting records from Database.
Please tell me how you did you fix the problem.
Hope this will help.
Thanx,
Regards,
yamini
|
|
|
|
|
I am a VB developer and hence using the VB terminology. So please bear with me.
The disconnected recordset did not worked with MS-ACCESS, the probable reason being,access being a file database, the file is closed as soon as the active connection of the recordset is set to nothing. This behaviour of the provider is be default and nothing can be done about it directly. (i.e. Set rs.ActiveConnection=Nothing wont work)
The only thing you can do is -
1. Return a connected recordset to client process (rs1).
2. Create a new Recordset in client process (rs2)
3. Add exactly similar number & type of fields to rs2 as in returned Recordset(rs1).
4. open recordset (rs2). without any connection or source.This should be dynamic
5. run a loop inside which you will add the records from rs1 to rs2
one at a time.
6. close rs1.
7. use rs2 as you wish
I have developed a small program in VB which you can refer & transpose to VC++.
The database is an access database with a single table "table1" with fields -
No Autonumber
Name Text(50)
===================================================
ActiveX dll
===================================================
Option Explicit
Dim conn As New ADODB.Connection
''''''''''''''''''''''''''''''''
Private Sub Class_Initialize()
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\1.mdb;Persist Security Info=False;"
End Sub
Public Function GetRsData() As ADODB.Recordset
Dim rs As New ADODB.Recordset
rs.Open "table1", conn, adOpenStatic, adLockReadOnly, adCmdTable
Set GetRsData = rs
End Function
========================================================================
========================================================================
The Client Executable
========================================================================
'A simple form with a single button placed & code for button click event
Private Sub Command1_Click()
Dim cls As New Class1
Dim rs1 As New ADODB.Recordset
Set rs1 = cls.GetRsData
Dim rs2 As New ADODB.Recordset
rs2.Fields.Append "No", adInteger
rs2.Fields.Append "Name", adVarChar, 50
rs2.Open "", , adOpenDynamic, adLockOptimistic, adCmdUnknown
Do Until rs1.EOF
rs2.AddNew
rs2("No").Value = rs1("No").Value
rs2("Name").Value = rs1("Name").Value
rs2.Update
rs1.MoveNext
Loop
rs1.Close
Set rs1 = Nothing
rs2.MoveFirst
Do Until rs2.EOF
MsgBox rs2(0) & " : " & rs2(1)
rs2.MoveNext
Loop
'If i halt the execution at this point and check for the active
'connection in debug window then it is found to be nothing.
'i.e ?rs2.ActiveConnection is nothing gives me TRUE!
'And there is your disconnected recordset(though not truely disconnected as it was never connected).
End Sub
I hope the above example would answer your query and help you in solving your problem.
do let me know if you get acheive any another solution.
regards,
Mangesh Sardesai.
|
|
|
|
|
Hi,
Thanx for the Reply.Actually ,I can't get that Recordset pointer at the client side.That is , it points to memory 0x00000000.So, I
could not access the Database using that NULL pointer.
My function at the server side goes this way .
STDMETHODIMP GetAllElements([out]IUnknown **ppRecordset)
{
//Here I am getting the Recordset Pointer.
}
Upto this step I can get the Recordset pointer
At the client side ,
void main()
{
IUnknown *pRecordset;
//Instantiate the Component & get the Interface pointer say pInterface.
pInterface->GetAllElement(&pRecordset);//pRecordset=0x00000000.Code Fails
//Accessing Records goes here
}
How should I pass the pointer if I am wrong at the Client side.
i am doing Standard Library Marshaling here.Is it to do something with this Marshaling !
Thanx in advance for the help.
Regards,
yamini
|
|
|
|
|
I have written an MMC snapin by inserting it as an ATL object in Visual C++ 6.0. However, when I run MMC with the snapin and I try to remove columns from the columns list using "change columns". I am able to remove columns from the "columns displayed" section, but, when I press OK and return to the snapin the column that I removed is still showing as a column header. Has anyone experienced this behaviour before and if so can you tell me how to rectify it.
|
|
|
|
|
Hi !
Contact me by mail and I'll send you a code... It's not easy to describe a solution in forum
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
what event/message occurs whenever i click the x button of the title bar? what i want to do is to display a confirmation dialog box before the application can be terminated. is this possible?
onyok
|
|
|
|
|
You'll get a WM_CLOSE message. Keep in mind you also get WM_CLOSE from ALT+F4 and the Close item in the system menu.
--Mike--
http://home.inreach.com/mdunn/
#include "buffy_sig"
|
|
|
|
|
Hello, the codegurus around the world.;)
We can filter some message to use CDialog::WindowProc function.
And as the previous poster pointed out, check WM_CLOSE message, and which control gets
input foucs or the other method like the mouse position(?)if we close x button of the dialog.
I guess that the function argument will deal with your requierment.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
I'm looking for any class that like the famous Oulook-bar control, is there any good one ??
Thanks much, Honza
|
|
|
|
|
http://codeguru.earthweb.com/controls/outbar.shtml
--------------
"Criticism is often constructive because it makes you feel superior when you give it"
-- Dogbert
|
|
|
|
|
Ok I want to write an application that interacts with a webpage in its CHtmlView..
I want to do the following:
1. Get feedback from the page on mouse-events, buttons clicked,... This I can do
2. Get interactive with the page and call javascript functions from the C++ code... This I can not do! Help!!
Can anyone help me to solve my problem?
thx
Wim Boffé
|
|
|
|
|
Hi,
I'm writing a postprocessor program for visualizing the results from
a Finite Element Analysis (FEA). The program is to be running in a
Windows NT/2000/98 environment.
I have three questions:
1. Is it possible to make a dialog transparent? If not, is it
possible to change the background color of it?
2. I don't manage to change the position of the tabs with the
CTabCtrl. They are on top now, but I want them to be on the right
side. There should be a command TCS_VERTICAL used with TCS_RIGHT but
when I do this, the tabs dont show up at all. Should I do something
extra?
3. I have'nt managed to disable some specific radio buttons on
the different tabs when the a specific solution is choosen (nodal
solution or element solution). When looking at a nodal solution all
radio buttons are to be enabled. But when pressing element solution,
specific radio buttons are to be disabled.
I use the following sequence:
m_first.GetDlgItem(IDC_RADIO101)->EnableWindow(FALSE);
RADIO101 is placed on dialog FIRSTDIALOG which belongs to CFirstDlg.
m_first is a CFirstDlg member. The program compiles, but there is a
runtime error when I press element solution. Any suggestions?
Best regards
Dennis Nilsson
M.Sc. Mech. Eng. Sweden
----------------------------------------
|
|
|
|
|
Question 1: Under W2000, yes. Under everything else there is a transparent flag, but it doesn't do much useful. Changing the background colour is easy - use FillSolidRect in OnPaint or OnEraseBackground
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I have a dialog with buttons and Listbox control. I know how to set the font of the dialog in Resources, but all controls have to use the same font. Can I set the dialog font in Time New Roman, and the Listbox control uses Courier New?
Thanks
|
|
|
|
|
Hello, the codegurus around the world.;)
Sure, we can do that.
After you create CFont object with each font type, and use SetFont to each control
to update the font type.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
I have a dialog-based app with a menu.
Now I want to extend the menu at runtime with other items (read from a file)
The example at codeproject didn't take me any further.
Now there's one problem:
CMenu *menu = GetMenu();
menu->AppendMenu(MF_STRING,ID_POPUP_DynCmd01 + (i-1) ,menuName);
The problem is that the new items are not inserted below the last item in the menu but right next to the first menu item. They're inserted this way:
[POPUP] [Dyn1] [Dny2] [Dny3] ...
but should be inserted that way:
[POPUP]
[Dyn1]
[Dyn2]
[Dyn3]
...
does anyone know why this happens that way?
thanks in advance
|
|
|
|
|
I found the error by myself. But now I have anonther problem:
Now all items are inserted in the right place, but when I use the flag "MF_POPUP" they are not inserted into the popup-menu
|
|
|
|
|
try this one:
TCHAR szString[256];
m_Menu.CreatePopupMenu();
/* insert items in m_Menu using the AppendMenu function */
pMenu = GetMenu();
pMenu->EnableMenuItem(ID_MENU_POPUP, MF_ENABLED);
pMenu->GetMenuString(ID_MENU_POPUP, szString, sizeof(szString), MF_BYCOMMAND);
pMenu->ModifyMenu(ID_MENU_POPUP, MF_BYCOMMAND | MF_POPUP, (UINT)m_Menu.m_hMenu, szString);
/* end */
ID_MENU_POPUP is the menu ID of the menu item where you want a popup menu to be inserted.
Make sure you destroy m_Menu after using it. Use the DestroyMenu function for this one.
|
|
|
|
|
I have a simple component written in c++ that uses Apache Xalan/Xerces to do XSL Processing - for the sake of getting to the heart of the problem I am having I have hard coded it to a small XML/XSL pair (strings in the code).
When I create an ASP page which uses this component it works fine the first time (outputs transformed XML) - but any number of times I try after that it is failing (outputs nothing). I have debugged into the Apache code and it seems to be failing at a custom smart pointer (as much trouble as help!) creation deep within the code for creating a source tree out of the XML (remember it works fine the first time) (XalanSourceTreeParserLiaison.cpp line 167).
Now the strange part is that if I create a VB test app to use my component it works fine every time.
The really unfortunate thing is that the Apache code has a try {} catch {} surrounding the code that fails but it is catching (...) (above it there are comments saying "need to fix this") so I cannot see what exception is being thrown.
Any thoughts? My assumption is that this has something to do with threading... But that's just my guess.
|
|
|
|
|
it turns out that inside of the Xerces code (which Xalan uses as an XML Parser - everyone act surprised) there is use of static function scope variables. These get initialized upon creation and stay around until the process they were created in dies.
the Xalan/Xerces system needs to be initialized/terminated, and in the termination process a number of objects that have been hanging around are deleted... one of them is a mutex object that was _pointed_ to by one of the aforementioned static function scope variables. This static function variable is returned by its function unchanged if it already has a value or with a new address (housing a new mutex object) if it is NULL. the returned handle to the mutex is fed to ::EnterCriticalSection() which will barf if the handle is invalid.
to recap - after you call Terminate() the handle isn't valid and since it is static and ASP doesn't unload dlls immediatly (it just loads that baby up and keeps on getting new handles to instantiations of the objects of it) the pointer to the handle is still around. so the next time that an ASP page is accessed which creates this object an exception is thrown within Xalan and no transformation takes place.
The solution is to Initialize() and Terminate() the Xerces/Xalan system at the process creation/deletion level which I did by adding the appropriate code to DLLMain and removing it from elsewhere. Now things work great and the only thing I have to worry about is the fact that from the time the DLL is loaded into memory by ASP to the time it is finally removed I have the Xerces system up and ready to go (potentially taking up memory....).
|
|
|
|
|
When I call MAPISendMail(..), it will only execute correctly if I have Outlook running. If Outlook isn't running I get a MAPI_E_LOGIN_FAILURE error returned. I've tried MAPILogon to create a session, still no luck. Any ideas?
|
|
|
|
|
Hey Kevin...how are you calling MAPISendMail?? You can specify as a calling parameter to popup a MAPI logon box to authenticate yourself...
Erik
I hit faked him with my win32 API .chm and the peabrain goes for it. I follow it up with a salvo of left's and right's sending him down hard. It's lunch time and he's getting a Champ Sandwhich Special. I said, How's that Mr. VB?! Is that 'I wanna use COM in that Server enough for you?!'
...Ever since then, I've been the Champ.
|
|
|
|
|
Hi there,
i'm curious about how does static_downcast and dynamic_downcast works ???
Thanks for any answer !
Have a nice day !
|
|
|
|