|
Homework time again.
This is so similar to previous posts I've seen, maybe the professor needs to update his/her lesson plans
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: similar to previous posts I've seen, maybe the professor needs to update his/her lesson plans
|
|
|
|
|
if inside the ctor of a class i have a local variable the type of which is another user-defined class, does it reside in the stack or the heap?
|
|
|
|
|
The reference will be on the stack, the object will be on the heap.
|
|
|
|
|
When I implement an interface explicitly like this
<br />
int IComparable<byte>.CompareTo(byte other)<br />
{<br />
...<br />
}<br />
I am unable to call it my self from another class, it does not show up in intellisence. Is this normal, if so why is it like this? I know that when I implement an interface like this is becomes explicitly public but I still cannot call it. This is for a value type also (I dont know if that makes any difference or not).
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
did you try something like:
class A:IComparable
{
}
______________________________________
A a = new A();
IComparable ia = a as IComparable;
if (ia!=null)
ia.ComapreTo(...);
I don't know if it'll work...you can try it
|
|
|
|
|
Explicit interface implementation allows you to implement an interface without adding public methods to your class. You will be able to call the method by casting an object instance to the interface type.
((IComparable)myInstance).CompareTo(other)
This is mainly used in two cases:
- there is another public method that does the same job and should be called instead (FileStream.Close vs IDisposable.Dispose)
- the method is expected to be only called by some other code that always operates on the interface and doesn't know about your class, and you don't want that the methods show when using your object. (often used with ICustomTypeDescriptor)
|
|
|
|
|
Daniel Grunwald wrote: You will be able to call the method by casting an object instance to the interface type.
((IComparable)myInstance).CompareTo(other)
I remember now. I did this last night...
IComparable<range> test = this;
test.[Intellisence found it];
It compiled without errors.
Thanks for the information.
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
I've been trying to use the Update method of the OleDbDataAdapter to update a MS Access database, but have not had success. I'm updating a DataTable object through several data bound controls and want to update the database using the values in those bound controls by simply clicking a 'Save' button. The Update OleDbDataAdapter method seemed the most appropriate method to use, but it hasn't worked. I don't get an explicit error, but no changes are made to the source database. Would anyone be able to suggest a reason for this? Thanks.
|
|
|
|
|
I assume that you assigned a command object to the UpdateCommand property of the DataAdapter.
If you have done that, then please check if you have access to update the table.
|
|
|
|
|
How would I check if I have access?
|
|
|
|
|
If it's a windows application just try a simple update query and see if you can update it
If it's a web application, try to give ASPNET account proper privileges
|
|
|
|
|
Thanks. Actually, that was not the problem. Basically, I wanted to use a DataGridView to display changes to the underlying data source, while using the data bound text box controls for editing purposes. Unfortunately, the way I set it up, the data table was not getting changed by changing the text box values.
Still, I have encountered another problem, and that is a concurrency violation. What could be the source of the concurrency violation?
|
|
|
|
|
concurreny problem occurs when more than 1 users are trying to update the same record, it might happen that one will end up changing a record that has already been modified by other users.
To fix concurrency violation, in your update query check if the record that you had read (and you're about to modify) has been modified or not. If it has been modified, don't update. Otherwise update it.
This is called optimistic concurrency control.
|
|
|
|
|
Thanks. I am certain that no other user is modifying the record. Could there be a concurrency violation because of some coding error?
|
|
|
|
|
can you please post the query that you're using and also the error message
|
|
|
|
|
Hi,
In my windows application if I'm getting ExternalException when I use the following to methods if the text parameter is too large.
g.MeasureString(text, font, size, format);
g.DrawString(text, font, color, rectangle, format);
I have tried to make the size and rectangle parameters to be large so that it fits the text, but I still get the same exception with Message : "A Genric error occurred"
Please let me know how I can fix this.
Thanks
Ben
|
|
|
|
|
How big is your string ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Length of the string 103325
|
|
|
|
|
Well, that's just silly
That error generally means you've used too much of a resource, or you've tried to use a resource that's not available to you. With that many chars, I am not surprised.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Is there any work around?
|
|
|
|
|
Instead of trying to draw one large string why don't you break it up and draw them individually?
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
I can, but I'm more interested in find out if there is a cutoff on the length of the string that gdi+ can handle thru these 2 methods.
|
|
|
|
|
GDI+ works with strings that are either "Pascal strings" (length + data) or "C strings"
(null terminated), so it has a explicit notion of string length (which gets set to -1
for C strings).
And I would not be surprised there are some 16-bit limitations to integer quantities
(hence max 65535 or even 32767 since -1 suggests signed integers are used for lengths).
one thing I found after a quick Google was:
"Due to a limitation of the GDI+ decoder, an System.ArgumentException is thrown if you construct a bitmap from a .png image file with a single dimension greater than 65,535 pixels."
If you really want to know, continue searching, or perform some experiments.
I would suggest trying string lengths of 32700, 32800, 65500 and 65600.
Luc Pattyn
|
|
|
|
|