|
Dear All,
I am working with ODBC API. My Requirement is to Move a Record to Move First Position, Last Position,Previous Position and Abosulte Position.
I dont want to use CRecordSet.MoveFist()... etc. Instead i am using ODBC Api's Like.
SQLAllocEnv(...)
SQLAllocConnect(...)
SQLDriverConnect(...)
SQLAllocStmt(...)
Etc... . With Api's I want to Move the Record to First,Last,Previous and Next Position of the Record. Please give me the Code Snippet to Move the Record to First,Next,Last and Previous Position. The Code must be in ODBC Only i dont want CRecordSet Wrapper.
How can we achieve this. Please Help Me Out. I want it Urgent.
Thanks in Advance.
Uday.
|
|
|
|
|
Check out SQLFetchScroll() and SQLExtendedFetch() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
This [^] maybe interesting for you.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Dear Pallini,
SQLHENV envHandle;
SQLHDBC ConnHandle;
SQLHSTMT StmtHandle;
SQLRETURN Ret;
SQLSMALLINT szConnStroutlen;
SQLCHAR sZ_AuthorName[50];
SDWORD sdoutputDataLen;
unsigned char szConnStrout[255];
Ret = ::SQLAllocEnv(&envHandle);
Ret = ::SQLAllocConnect(envHandle,&ConnHandle);
Ret = ::SQLDriverConnect(ConnHandle,
NULL,(SQLWCHAR *)_T("Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:\\Uday.mdb"),
SQL_NTS,(SQLWCHAR*)szConnStrout,sizeof(szConnStrout),&szConnStroutlen,SQL_DRIVER_NOPROMPT);
Ret = ::SQLAllocStmt(ConnHandle,&StmtHandle);
//To Fetch a Relative Record.
Ret = SQLFetchScroll(StmtHandle,SQL_FETCH_FIRST,0); ---> //Here it is Failing Help me out Please.
Thanks & Regards,
uday
Please Help me Out.
|
|
|
|
|
janaswamy uday wrote: Ret = SQLFetchScroll(StmtHandle,SQL_FETCH_FIRST,0); ---> //Here it is Failing
Meaning what?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Dear David,
I am not getting a Correct Output for the APi what i have used.
Please help me out.
Thanks & Regards,
Uday
|
|
|
|
|
janaswamy uday wrote: Ret = SQLFetchScroll(StmtHandle,SQL_FETCH_FIRST,0); ---> //Here it is Failing Help me out Please.
Have you taken a look at the "Returns" and "Diagnostics" sections of the Docs for SQLFetchScroll[^] function? What is the return value, and if it is a failure, what does the diagnostics reveal?
The solution to your issue may be right there.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
I really would like to help you, but.....The other guys already did.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi Every one.
actually It's the first time I use CSpinButtonCtrl in Visual Studio 2008 sp1
But it seems that it's not working with it's buddy control (in fact it does not do anything)
, here is my code in OnInitDialog() method, any Idea if I forgot something here!
CSpinButtonCtrl* pSpinCtrl = (CSpinButtonCtrl*)(this->GetDlgItem(IDC_SPIN1));
pSpinCtrl->SetBuddy(GetDlgItem(IDC_EDIT_SPIN_BUDDY));
pSpinCtrl->SetRange32(10,500);
pSpinCtrl->SetPos32(20);
|
|
|
|
|
Amir_m wrote: CSpinButtonCtrl* pSpinCtrl = (CSpinButtonCtrl*)(this->GetDlgItem(IDC_SPIN1));
pSpinCtrl->SetBuddy(GetDlgItem(IDC_EDIT_SPIN_BUDDY));
pSpinCtrl->SetRange32(10,500);
pSpinCtrl->SetPos32(20);
I don't see any problem with your code. Did you forget to set the "Set Buddy Integer" property of the spin control to true? If not, try that. Additionally, I would recommend that you add a control type member variable to your edit box (the buddy control), say m_Edit and add a control type member variable to the spin control as well (say m_Spin ). And then rewrite your code like this:
m_Spin.SetBuddy(&m_Edit);
m_Spin.SetRange(10,40);
m_Spin.SetPos(12); This way, you could avoid the casts, avoid an extra pointer variable, and avoid GetDlgItem [^]
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
guys...
i want to do a software to read text data and display the text...
this was the idea...the program should read the txt file...when the file was open, it will display one by one of the text...can anyone help me with this?? please...
|
|
|
|
|
Read point 2 here[^]
In other words, were are you stuck ? What is your problem, what did you already do ?
|
|
|
|
|
for your information...i'm very new for VS C++ programming..
the program i want to try create program like this:
http://www.mediafire.com/?ymdzm2tjmdn[^]
i want to know either i can create program like this using MFC???
|
|
|
|
|
mr bard2 wrote: for your information...i'm very new for VS C++ programming..
Then I strongly suggest to buy a good book about the MFC and start to learn from the basics. You won't achieve a lot if you don't have at least a basic understanding of the MFC. And learning through a book is usually much faster than asking help from people.
|
|
|
|
|
mr bard2 wrote: i want to do a software to read text data and display the text...
This is a fairly basic question with many samples around, take a look here[^], as a starting point.
|
|
|
|
|
Have you looked at CStdioFile and its members?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi, see here[^]
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Hello Everyone,
This is my 2nd Post regarding the Text extraction from the WebPages.
In my Previous post David Crow suggested me use IHTMLDocument2 interface,
In the code project depository I found this application
Parsing HTML using MSHTML [] by Philip Patrick ..Extracts all the links in the WebPages Using HREF Tag,
Can I use the same application to extract the Text from the Table from the WebPages ?
I searched for Table tag from which I can extract the text, I did not find any information. Can anyone please tell me is it possible to use MSHTML using IHTMLDocument2 interface can I extract the Text from the <table> Tag.
Thanking you,
Naveen HS.
void CTestDlg::OnBgo()
{
UpdateData();
CWaitCursor wait;
if(m_csFilename.IsEmpty()){
AfxMessageBox(_T("Please specify the file to parse"));
return;
}
CFile f;
if (f.Open(m_csFilename, CFile::modeRead|CFile::shareDenyNone)) {
m_wndLinksList.ResetContent();
CString csWholeFile;
f.Read(csWholeFile.GetBuffer(f.GetLength()), f.GetLength());
csWholeFile.ReleaseBuffer(f.GetLength());
f.Close();
MSHTML::IHTMLDocument2Ptr pDoc;
MSHTML::IHTMLDocument3Ptr pDoc3;
MSHTML::IHTMLElementCollectionPtr pCollection;
MSHTML::IHTMLElementPtr pElement;
HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IHTMLDocument2, (void**)&pDoc);
SAFEARRAY* psa = SafeArrayCreateVector(VT_VARIANT, 0, 1);
VARIANT *param;
bstr_t bsData = (LPCTSTR)csWholeFile;
hr = SafeArrayAccessData(psa, (LPVOID*)¶m);
param->vt = VT_BSTR;
param->bstrVal = (BSTR)bsData;
hr = pDoc->write(psa);
hr = pDoc->close();
SafeArrayDestroy(psa);
pDoc3 = pDoc;
pCollection = pDoc3->getElementsByTagName(L"A");
for(long i=0; i<pCollection->length; i++){
pElement = pCollection->item(i, (long)0);
if(pElement != NULL){
m_wndLinksList.AddString((LPCTSTR)bstr_t(pElement->getAttribute("href", 2)));
}
}
}
}
modified on Thursday, October 15, 2009 8:30 AM
|
|
|
|
|
|
Hello Sir,
Thank you very much for the response.
I have added this lines to the above code.
MSHTML::IHTMLDocument2 *pDoc1 = NULL;
MSHTML::IHTMLElementCollection *pColl = NULL;
pColl = pDoc1->get_all(L"table");
int y = pColl->length;
for(int x = 0; x < y ; x++)
{
}
i am getting the following Error :-
error C2664: 'MSHTML::IHTMLDocument2::get_all' : cannot convert parameter 1 from 'const wchar_t [6]' to 'MSHTML::IHTMLElementCollection **'
|
|
|
|
|
NaveenHS wrote: pColl = pDoc1->get_all(L"table");
This is wrong.
get_all will give you all elements and not all tables.
get_all takes the IHTMLElementCollection pointer as the parameter.
As a general rule, all COM calls in C++ will return an HRESULT .
Except maybe AddRef and Release .
So you will have to check the tag name in a loop to see if they are tables.
So the get_all call would look like this -
pDoc1->get_all(&pColl);
I would recommend using ATL here.
Otherwise you will have to remember to call Release for all these pointers.
So my recommended way would look like this -
CComPtr<MSHTML::IHTMLElementCollection> pColl = NULL;
pDoc1->get_all(&pColl);
You can use the IHTMLElementCollection::item[^] method to get an IDispatch pointer to each element in the collection.
This can in turn be QIed to an IHTMLElement[^] or IHTMLDOMNode[^] interface.
Check the methods of the interfaces to identify the table tags that you need.
|
|
|
|
|
Hello Sir,
Thanks a lot for the reply.
I made changes as mentioned by you, but still i am not able to extract the data from the table. can u please tell what change i have to make.
MSHTML::IHTMLDocument2Ptr pDoc;
MSHTML::IHTMLDocument3Ptr pDoc3;
MSHTML::IHTMLElementCollectionPtr pCollection;
MSHTML::IHTMLElementPtr pElement;
HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IHTMLDocument2, (void**)&pDoc);
pDoc3 = pDoc;
pDoc->get_all(&pCollection);
pCollection = pDoc3->getElementsByTagName(L"table");
for(long i=0; i<pCollection->length; i++){
pElement = pCollection->item(i, (long)0);
if(pElement != NULL){
m_wndLinksList.AddString((LPCTSTR)bstr_t(pElement->getAttribute("table"),10));
}
}
Error :- error C2660: 'MSHTML::IHTMLElement::getAttribute' : function does not take 1 arguments
|
|
|
|
|
The syntax for getAttribute is not correct.
Do it this way -
CComBSTR name("table");
VARIANT result;
pElement->getAttribute(name, 0, &result);
|
|
|
|
|
Hello sir,
I added the code , still getting the error.
pDoc->get_all(&pCollection);
pCollection = pDoc3->getElementsByTagName("table");
CComBSTR name("table");
VARIANT result;
for(long i=0; i<pCollection->length; i++){
pElement = pCollection->item(i, (long)0);
if(pElement != NULL){
m_wndLinksList.AddString((LPCTSTR)bstr_t(pElement->getAttribute(name, 0, &result)));
}
}
I am getting the below error :-
error C2660: 'MSHTML::IHTMLElement::getAttribute' : function does not take 3 arguments
|
|
|
|
|
I'm getting an error message with this line of code, int _int tmain (int argc,_TCHAR* ARGV[]) ,the error E2303 says "Type name expected".
Can somebody advise me, please?
|
|
|
|