|
worked perfectly, thanks a lot
-Raffi
|
|
|
|
|
Hi All
I am trying to connect to SQL Server using the ODBC classes. In my sql to CRecordset.Open, I provide a query which looks like:
CString sSql = "select ani from cxcu where company = ' + sCompany;
cxcu is a very large table and the query will return upward of 600k records. I am also turning on the CRecordset::useMultiRowFetch option.
What I want to do is to lookup an "ani" ( from above query ) and check if it exists in the table or not.
Would it make sense if I connected with a NULL string and then called Requery()? I am having to wait for a very long time (in excess of 15 minutes) for the CRecordset.Open(...) to complete.
What would be the best way to do this lookup of a record in amongst 600k+ using CRecordset?
Thanks
ashish
|
|
|
|
|
Have you investigated as to how long will it take for the query to execute from QueryAnalyzer in SQlServer itself? If not you may want to do that and then see what type of indexing may be required to make your query go faster.
If the existing WHERE clause is returning 600K plus records and you wish to run this query only to see if this company exists then try to tighten the WHERE clause such that the number of records returned is smaller.
|
|
|
|
|
Thanks Ranjan. Here is what I am currently doing:
Since the lookup has to be from a table with 600k+ records, I have to load it using CRecordset.Open. This would take me upwards of 10-15 minutes.
Now, to avoid this, what I am having to do is to call CRecordset.Open and CRecordset.Close to check each input value.
So what I am doing is setting the SQL and m_strFilter for each check I am performing. I am lucky that the field "ani" is indexed in the database.
Surely there is better way to do this????
thanks
ashish
|
|
|
|
|
I've just started learning VisualC++. I'm using Ivor Horton's book "Introduction to MS VisualC++ Standard Edition". I'm in chapter "MFC Dialog Programming".
I have a problem with a ComboBoxEx.
I put it on a form and add a member variable for it (Variable type is set to Value) m_strCboEx. Then, I add several items to the item-list.
At this stage, everything is working as I expected - whatever I choose in a running program it goes to m_strCboEx.
However, when I change combo's style to DropList - m_strCboEx is always an empy string at the end.
Why is it so?
I tried to use standard ComboBox instead of ComboBoxEx and in this case everything was OK.
I don't understand...
Can you help me?
Maciek Niedzielski
|
|
|
|
|
I have a CEdit control on a CFormView (didnt create it in code). I set its visible property to invisble. Now I want it to show up at runtime under certain conditions. How do I do this? Says Visible(TRUE) is not a property of Cedit....
Thanks,
Ns
|
|
|
|
|
OOps! It was ShowWindow(SW_SHOW).
Thanks anywyas,
ns
|
|
|
|
|
If anyone could help me with this I'd appreciate it.....
I've been trying to find out how to open a serial COM port through Visual C++ 6.0.
There is a sample code at http://www.codeproject.com/managedcpp/howtocomport.asp , but it doesn't work in Visual C++...
does anyone know what changes I have to make??
|
|
|
|
|
HANDLE hPort=CreateFile(
"\\\\.\\COM1",GENERIC_READ|GENERIC_WRITE,0,NULL,
OPEN_EXISTING,0,NULL);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi.
I have discovered a major bug in a simple program. The problem has a propertysheet. There are two pages the are almost exactly the same. Both pages have a CListCtrl box. In both pages, the user can add items, select items, and/or remove existing items.
For some reason, only one page worked in the *release* version of the program. Everything worked perfect in debug mode, but one page crashed in release. The page that crashed does so in the same manner every time. Below is a logs of the crash.
// debug log
-----
// this occurs AFTER the user options a propertysheet
// program does NOT crash at this point
First-chance exception at 0x7196254a in myProgram: 0xC0000005: Access violation writing location 0x00463b2c.
// this occurs when the user selects an item in a CListCtrl box
// program crashes at this point
First-chance exception at 0x046936d7 in myProgram: 0xC0000005: Access violation reading location 0x046936d7.
Unhandled exception at 0x046936d7 in myProgram: 0xC0000005: Access violation reading location 0x046936d7.
The program '[1120] myProgram: Native' has exited with code 128 (0x80).
-----
I have no idea how to fix this problem. I have compared the two property pages I mentioned that have the CListCtrl boxes. The code in both property pages are flawless.
First, I thought the program crashed because there was a code program in the function that determines what item is selected in the CListCtrl box. However, I have found that the program does not crash at all inside that function. It crashed sometime after leaving the function.
Is this a memory problem? Please post if you have any idea on debugging this problem.
Thanks,
Kuphryn
|
|
|
|
|
Unless there's someone else here with strong divination capabilities, a little more help from you would be great. It could have to do with the data you're using to feed the controls (uninitialized arrays or something.) You can also take a poor-man approach to release mode debugging plaguing your code with MessageBox es and try to determine the exact location where the error is happening.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks.
When the program crashed, Visual C++ points to the line that caused the crash. In this case, it points to the following line from *cmdtarg.cpp*.
Note: cmdtarg.cpp is NOT part my the program. I have no idea what where Visual C++ gets it.
-----
// cmdtarg.cpp
#endif //_DEBUG
// this line
-> return _AfxDispatchCmdMsg(this, nID, nCode,
lpEntry->pfn, pExtra, lpEntry->nSig, pHandlerInfo);
}
}
-----
Kuphryn
|
|
|
|
|
Seems like somehow you have corrupted the stack. Is there any loop in one of your handlers that might be going out of bounds?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
To be honest with you, I have no idea where to even start debugging it.
My best guess right now is it has something to do with maybe the property sheet because this problem occurs after the user opens options.
Kuphryn
|
|
|
|
|
Okay. I have found the problem.
The problem has to do with the way I was determining the state of an item in a CListCtrl. I had to change the algorithm. Now the program no longer crashes.
MFC does some really weird stuff in the background. Be careful or you might end up with many problems.
Kuphryn
|
|
|
|
|
I have a operation which writes a string to a ListBox. Followed by anther function. The problem is the other function starts before the string is displayed in the list box. i:e
plistbox.AddString("xyx"); // writes string to list box
if(!(my_function()))
{
// fail
}
else
{
// pass
}
How do I make sure the ListBox has been updated before the next function is called.
Any help would be appreciated
Thanks
The problem is the next process seems to start before the string is displayed in the ListBox.
Desmond Mardle
|
|
|
|
|
Your problem has nothing to do with overlapping processes or anything like that. Try calling plistBox.RedrawWindow() after adding the string (and before calling my_function .)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your help. Problem solved:
Desmond Mardle
|
|
|
|
|
If I understand the problem correctly try:
UpdateData(FALSE);
Between writing the string and calling the function.
Mike Mullikin - People demand freedom of speech as a compensation for the freedom of thought which they seldom use.
Soren Kierkegaard
|
|
|
|
|
Hello,
In this type of application where the left pane is a treeview and the right pane is a listview, how do you keep the input focus on the left pane?
Example, I need to be able to perform needed operations on the right pane while the item in the tree is selected.
Is this possible?
Thanks,
Frank
|
|
|
|
|
I'm trying to get a handle (no pun) on threads.
I've got a function that calls two functions one after the other then returns. I'd like to multithread it because the functions lock up the UI in my App.
So...Question #1: When multithreading a function are the actions performed in the functions called from that function also performed in the new thread?
Question #2: Whats the easiest way to implement something like this?
Frank
|
|
|
|
|
#1. Yes. The whole function is executed in the new thread, which exits when the function exits. For instance:
DWORD WINAPI MyThread(LPVOID arg){
function1();
function2();
return 0;
}
DWORD dwThreadId;
HANDLE hThread=CreateThread(
NULL,
0,
MyThread,
NULL,
0,
&dwThreadId
);
#2: The code above just answer this. For production level code you'll need some more stuff (to control when the thread exists, for instance) but this piece of code should get you started.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Great! Thanks for the info.
Frank
|
|
|
|
|
I never want any scrollbars to show up in my MDI. Any way? I tried tthe cs but it want realy responsive. MAybe I didnt try enough? ?
Thanks,
ns
|
|
|
|
|
I am going to have to abandon my oh-so-cool MDI approach since I cant get around a movewindow issue which I'll describe in a bit. SO I am thinking SDi. But I need two views. Can an SDI handle two views?
The MDI dilemma:
Four edit boxes are supposed to hug the right edge always, even on resize. SO onsize I did movewindow setting the top y value to 10, 50, etc....
Fine. But if I scroll without resize, and some are off the visible part, then resize, they immediately pop back at 10, 50 etc from the top edge, leaving a big blank space above in the scrolled off portion. No matter whats the visible screen area, they alwyas show up at 10,50 etc from the top, on resize, leaving gaps where they should have been....
Any solution to this? I do like the MDI otherwise. LOts of hard work ahead if SDi wont do two views....
Thanks,
ns
|
|
|
|