|
Its the connection pConn and you had already opened it and then attached it to your pCmd
hence it was open before you called Execute.
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
My ADO is pretty poor but I don't think you have to open the recordset - I think you can just get on tith reading from it after you have called Execute
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
thanks for the feedback. but one silly question:
what does it mean by pRs->Close()??
pConn->Close() is an API that tells SQL server to drop the connection and it is NOT equivalent to "delete pConn". That's okay and I can understand.
But recordset is a data structure. What do u mean by "closing" a data structure? remove it from memory?
I am confused by the two concepts:
1. closing... a memory/variable?
2. removing a variable from memory/stack/...etc
thanks.
norm
|
|
|
|
|
from MSDN:
"When you have concluded your operations over an open Recordset object, use the Close method to free any associated system resources. Closing an object does not remove it from memory; you can change its property settings and use the Open method to open it again later. To completely eliminate an object from memory, set the object variable to Nothing"
so, what about the connection object associated/attached to a recordset?
norm
|
|
|
|
|
I'm using a CRichEditCtrl object as one of the many windows in an app, and now need to use print preview. I have other windows, such as grids, and everything works fine except....
I'm using RT v3.0 control under NT4/2000/XP. When I ask it to format for printing, the rendering dc and formatting dc are the same (m_hDC and m_hAttribDC respectively), and it looks OK. When I format it for preview, the rendering DC and formatting dc aren't the same (which you'd expect, I guess).
However, it consistently doesn't preview the final line on the 'page' (ie in the rect I've given it. Now I know that it's a preview, but my customers expect WYSIWYG, so they'll complain about missing lines;
I'm rendering to a memory dc and blitting, but I know it's not the blit doing the clipping, as this is 'transparent' to the printing (it's done in OnPrint for every page, and the rect for printing the RTF is way smaller than the page).
Can anyone point to an RTF rendering example that works with MFC's print preview (or not, if it renders to a memory dc!) that doesn't exhibit this problem?
I'm using FormatRange and DisplayBand to do the formatting and rendering, but MSDN seems pretty light on preconditions for these, doesn't mention stuff like mapping modes needed etc, although it seems that the DC has to be MM_TEXT before it works at all.
Steve S
[This signature space available for rent]
|
|
|
|
|
Im having a similar problem with previewing a RTF. Im not using FormatRange neither Display band; im using PrintInsideRect, which is working fine except for some problems not related to this.
Be carefull because there are different ways to get the total number of chars in the RichEdit. You have to be coherent between the different functions that may use the number of chars you want. For example, PrintInsideRect retrieves the amount of chars that fit in a specified are, but that amount may not be the same if you use some other function, as it may count some other chars like CR/LF, etc
That way, you final line may not appear because you're not sending enough chars.
|
|
|
|
|
Thanks for that.
I don't think it applies in this case though, as I'm consistently using FormatRange to get the next character (ie starting position), and I'm getting the same values for both preview and print modes. However, it does give me a few ideas which I'll try later; if it works, I can feel an article approaching.
If only MS had documented this better, it would be far simpler.
Steve S
[This signature space available for rent]
|
|
|
|
|
I've had problems with print previews in the past. Mostly what I've seen are roundoff errors in line spacing between the printed version and the screen version. Tweaking the font values for the screen version did the trick.
Software Zen: delete this;
|
|
|
|
|
Yes, me too, been there, done that, bought the T-shirt...
I learned from experience that a more reliable way when using MFC without wanting to break absolutely everything was;
In OnPrint, check if we're previewing; if so, create a printer-page sized bitmap, and a memory dc with it selected, and use this for output (I do this by having a RealPrint(CDC*, CPrintInfo*) function which does only the output), otherwise used the passed dc for RealPrint.
On return from that, if we're previewing, blit the memory dc to the passed dc, then cleanup.
Gives much better results, IME.
My problem is subtly different, in that it would consistently not print the last line, and since the measuring & rendering was being done by a control, I didn't really want to have to write an RTF interpretation and layout engine.
However, thanks to Miguel, who put me on the right track. It turned out that I was clearing the control's cache using FormatRange(NULL,FALSE) in between calls to the real FormatRange(), so I was getting inconsistent numbers back.
Now fixed.
Steve S
[This signature space available for rent]
|
|
|
|
|
how to disable the maximize in win32 application.
IAM USING createwindow function.
how to disble it.
|
|
|
|
|
If you simply want to get rid of the maximize box and prevent it that way, you just need to make sure that the WS_MAXIMIZEBOX style is NOT set for your window when you create it.
If you want to prevent it programatically you will need to handle the WM_SYSCOMMAND message and look for the SC_MAXIMIZE code.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
no i try to use ~ws_maximize but i dont know how to use it correctly.
~ws_maximize & WS_VISIBLE|WS_CHILD like that
Is it correct or not.
|
|
|
|
|
Hey, I plan to have a window that has like a list on the left to select items, and when selected the rightView changes, i've got the splitter happening and should be able to put a listview in the left. But I was wondering whats the best approach for havn't different pages in the right view? Like one would be lots of edit boxs and labels, and another would be text area or a listView. Whats the best way? Just having the rightview with are the member varibles and cahanging which ones in view?
I'm really just looking for a push in the right direction, maybe a tutorial, example or just what classes I should be reading about.
thanks,
Luke.
|
|
|
|
|
You may inherit your right view from CFormView and place there whatever you want.
if you want more than 1 pages on the right, you may use some tab controls like CXTabCtrl (http://www.codeproject.com/tabctrl/cxtabcontrol.asp).
I've used it it my project once.
Dmitry Timin
|
|
|
|
|
can u use HRESULT_CODE in VC's tool "Error Lookup"?
norm
|
|
|
|
|
Yes. The ErrLook.Exe program is a simple little wrapper around the FormatMessage() API function. As a result, any error code that it can recognize, the ErrLook program can display. Note that not all HRESULT 's have messages, which is why some of them don't display anything.
Software Zen: delete this;
|
|
|
|
|
hi, writing a win32 console app that doesnt support MFC (besides CDBException is for ODBC ..)
i opened a recordset and since the open method doesnt return a HRESULT, i need to use try-catch mechanism.
but how?
try
{
pRs->Open(....);
}
catch( what?)
{
}
Reference:
recordset.Open Source, ActiveConnection, CursorType, LockType, Options
(Note: No return value)
thanks gurus!
norm
|
|
|
|
|
if you catch (...), you'll catch all exceptions. There is a com_exception, or similar, but I forget exactly what it's called.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
just found out...
try
{
pRs->Open(vNull, vNull, adOpenForwardOnly, adLockReadOnly, adCmdUnknown);
}
catch(_com_error &e)
{
//Additional error handling here.
cout << "ERROR: Failed to open recordset." << endl;
cout << "ERROR msg: " << e.ErrorMessage() << endl;
}
But the error msg is soooo vague:
Unknown error 0x800A0E79
I'm banging my head against my cactus but apparently it doesnt help
norm
|
|
|
|
|
In the tools menu of VC is an error number checker. Put this number into it and it will pop up a dialog that says 'error message not found'. Or, 1 in 1,000 times, it knows what this HRESULT means, and then it tells you
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
tried, it says cant find the message ("Message not found") with "0x800A0e79"..
the tool is called "Error Lookup"
catch(_com_error &e)
{
//Additional error handling here.
cout << "ERROR: Failed to open recordset." << endl;
cout << "ERROR: e.ErrorMessage(): " << e.ErrorMessage() << endl;
hr = e.Error();
cout << "ERROR: HRESULT_CODE( e.Error() ): " << HRESULT_CODE(hr) << endl;
}
But if Error Lookup HRESULT_CODE(hr)==3705 gives the following msg "Bad or missing LAN Manager root directory." --- this doesnt make a lot of sense coz it's a local SQL server and previous statements all executed with good HRESULT==S_OK
norm
|
|
|
|
|
sorry, for error = 3705, Error Lookup yeilds "Message Not Found"
oops
norm
|
|
|
|
|
how can u enumerate tables given a database?
btw, we use ADO for database access. and we use SQL server.
thanks!
norm
|
|
|
|
|
Read my article called MSDEGUI - the queries I use there should work for you. It's in the new list on the main page.
No, I don't remember them, or I'd just tell you
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
just scan yr article briefly. isnt it for .NET?
anyway, i'm building all my code with VC6 - lots of anti microsoft types here in this company.
anyway, i am thinking, perhaps I can read MyDB.Tables.sysobjects
there're three columns of interests:
a. "names" -- object name: a simple string
b. "id" -- object id: just a simple integer
c. "xtype" and code as follows:
Object type. Can be one of these object types:
C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
L = Log
FN = Scalar function
IF = Inlined table-function
P = Stored procedure
PK = PRIMARY KEY constraint (type is K)
RF = Replication filter stored procedure
S = System table
TF = Table function
TR = Trigger
U = User table
UQ = UNIQUE constraint (type is K)
V = View
X = Extended stored procedure
So, I will just count and retrieve an array of names (names - column one of sysobjects table) for all entries where xtype==U
norm
|
|
|
|
|