|
I am writing a simple DOS applicaion that is using ADO to connect to data source. The COM libraries are initializing successfully and the connection to database by connection pointer is also established.
But when i try to run a "query" using connection pointer, the following exception is raised:
Error:800a0e81.
ErrorMessage:Unknown error 0x800A0E81.
Source:ADODB.Connection.
Description:Operation cannot be performed while connecting asynchronously..
Can any one tell me why this happens ???
Here is my code:
_bstr_t bstrQuery("SELECT * FROM Customers");
_variant_t vRecsAffected(0L);
_RecordsetPtr pRecordSet;
pRecordSet = m_pConnection->Execute(bstrQuery, &vRecsAffected, adOptionUnspecified);
|
|
|
|
|
Just a stab in the dark, but you might need to create an instance of the
Recordset object
_RecordsetPtr pRecordset = NULL;
pRecordset.CreateInstance(__uuidof(Recordset));
chin
|
|
|
|
|
|
Your original error message mentions something about an asyncronous connection. This may be the root of all your evils
An asyncronous ADO connection requires a lot more construction code that
your entire program may be missing.
I have done a quick test and it seems to work ok.
I've provided the console function below for you to look at.
void ConnectAndDisplay()
{
CString strSQL;
_variant_t vtAffected;
_variant_t vtField;
_ConnectionPtr pConnection = NULL;
_RecordsetPtr pRecordset = NULL;
strSQL = "Select [Name] From [CustomerTable]";
try
{
TESTHR( pConnection.CreateInstance(__uuidof(Connection)) );
TESTHR( pRecordset.CreateInstance(__uuidof(Recordset)) );
TESTHR( pConnection->Open( _bstr_t(_T("File \\MyConnection.udl;")), "", "", NULL ) );
pRecordset = pConnection->Execute((LPCTSTR)strSQL, &vtAffected,adOptionUnspecified);
while( pRecordset->ADOEOF != VARIANT_TRUE )
{
_variant_t vtField;
CString strField;
vtField = pRecordset->Fields->GetItem("Name")->Value;
ASSERT( vtField.vt == VT_BSTR );
strField = vtField.bstrVal;
cout<< (LPCTSTR)strField << endl;
pRecordset->MoveNext();
}
pConnection->Close();
}
catch(_com_error e)
{
CString strMessage;
strMessage.Format("Error: %s\n", e.ErrorMessage());
AfxMessageBox(strMessage);
}
return;
}
Chin
|
|
|
|
|
This code must be incomplete. We don't see the code for creating the Connection object.
Also, you may want to work only with the recordset object, unless you want to reuse the connection for other queries.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Hello!
As far as I know there is a macro or something like that to get single text-items which are defined in the string-table resoure. I haven't found anything at msdn, but I know there is a macro which is able to get the text from the string table via the ID like GetDlgItem(ID).
Does anybody know what I mean and please can anybody help me? I'm getting crazy...
thanks in advance
fl
I don't want achieve immortality through my work - I want achieve it through not dying - Woody Allen
|
|
|
|
|
LoadString .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You tried LoadString, didn't you?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
thanks! I have tried LoadString but don't know how to handle the parameters. Finally I've found MAKEINTRESOURCE macro which works well (but needs some typecasting for working with CStrings)
thanks!
I don't want achieve immortality through my work - I want achieve it through not dying - Woody Allen
|
|
|
|
|
CString str;<br />
str.LoadString(IDS_MYSTRING);<br />
|
|
|
|
|
I want to prepare a installer for my application which should be able to start installation program automatically. I have already preapred a setup program using installshield. Now I want to put my application on net and just like Yahoo messanger download I want that setup.exe should be copied to client's side and after completion it should start installation automatically.
Is it possible? Please help me.
|
|
|
|
|
how to get current window hwnd while i am in dlg class ?
r00d0034@yahoo.com
|
|
|
|
|
What do you mean by
i am in dlg class
???
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
You can always use:
<br />
this->GetSafeHWnd()<br />
.. from within your CDialog derived code (or any CWnd derived class for that matter).
chin.
|
|
|
|
|
CInsDWFirstDlg* pInsDWFirstDlg;
pInsDWFirstDlg=new CInsDWFirstDlg();
pInsDWFirstDlg->Create (IDD_InsDWFirst,this);
pInsDWFirstDlg->ShowWindow (SW_SHOW);
CInsDWFirstDlg is a Modal Window ,but if I use above method to display it ,it is not Modal Window.
I don't want to use pInsDWFirstDlg->DoModal()
How I display it as Modal Window in MDI window ?
thank you
|
|
|
|
|
What does prevent you from using
CInsDWFirstDlg dlg;
dlg.DoModal();
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Has anyone tryed a USB comunications object for sending data to a divice connected to ther USB port
Rich
|
|
|
|
|
Hi
I have a dialog-based application, where a user can either click on buttons or use the keyboard.
Since there are many buttons, I have handled mouse button clicks in the OnCommand handler. Now, I don't want to duplicate keyboard messages. So is there a way to map the keyboard messages to the mouse clicks?
Regards
Sridhar J
|
|
|
|
|
You should rather map keyboard messages to WM_COMMAND directly using accelerator table.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Hello
Thanks for your quick reply.
What I want to do is something like in the windows Calculator. When a number is pressed on the keyboard, the button acts as if it is clicked and the same code as a button click is executed. How do I do this?
Regards
Sridhar J
|
|
|
|
|
sridharj wrote:
When a number is pressed on the keyboard, the button acts as if it is clicked and the same code as a button click is executed
In this case, handle WM_KEYDOWN or WM_CHAR and send BM_CLICK to appropriate button. You'll probably want to map key codes to button control IDs to avoid huge switch(...) statement. Use CMap or std::map for that.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Hello
Thank you very much. Although, I usually do not post thank you messages too often, since it wastes the other persons' time, I feel I can make an exception here.
Please look out, since I have a lot of questions.
Each will have its own thread, since people can read and learn without asking again.
Regards
Sridhar J
|
|
|
|
|
I want to change the cursor to an Hourglass while my program is busy. I thought this would be simple but I cannot find it my books, in the help or on CP, maybe I'm searching for the wrong thing!
Anyway, can anyone tell me how to do it or where to look.
Cheers,
Ali
|
|
|
|
|
BeginWaitCursor(), to change to hourglass
then EndWaitCursor() when done.
chin
|
|
|
|
|
Excellent, thank you very much. I thought it should be simple, just couldn't find it.
Thanks again,
Ali
|
|
|
|