Nerseus
*Experts*-
Posts
2607 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Nerseus
-
Check out QueryPerformanceCounter on google or these forums. -Nerseus
-
From my limited digging, you just can't get the size of a managed class - at least through no publicly exposed interface anyone is talking about. Maybe there's a hidden API, but no one's talking. I'm not sure if this will help, but you can get a pointer to any object through the use of a GCHandle object. Check the help on how to use it. Make sure you specify "pinned" memory when you create the handle and then you can safely pass the returned pointer (handle.AddrOfPinnedObject) to an API, if that's what you want/need. -ner
-
As I said, bools are value types - any new "pointer" (variable) to a bool gets a copy. It doesn't matter if you box it, if you use ByRef, etc. The only place where you can change the original value is in the constructor, since that code has the ByRef argument. Assigning that to ANY other variable (boxed/unboxed/object/etc.) will get a COPY, not a pointer. You could solve this in 2 ways off the top of my head: 1. Have the child form S expose a bool value that form F reads. 2. Wrap your bool value in a class and pass the class to the constructor of S. For #1, you would change prBoolean in form S to be public. When you get control back in form F, you could reference form S's prBoolean variable to set the value of myBool. That puts the onus on form F to use the value that form S is giving you. For #2, you would create a new class that contains one bool property. Form F creates the class and passes it to form S. Form s saves that reference in its own variable. Then in form S, changing the bool value will change the underlying bool value. As a side note, the data in a class is always passed by reference. Only the pointer to the class is passed by value or by reference, based on the param type. Meaning, even if you changed your constructor to use ByVal for the class parameter, you could STILL change the bool value contained within it. To do #2, do something like this (this is C#, but you can follow): public class BoolData { public bool BoolValue; // Constructor takes a bool to default public BoolData(bool initValue) { BoolValue = initValue; } } // In Form F { .... private void CallFormS() { BoolData o = new BoolData(); FormS s = new FormS(true); s.ShowDialog(); // Right now, if s changed the bool value, it is changed here: // So o.BoolValue is whatever it was changed to on S } } // In Form S { private BoolData b; // constructor public FormS(BoolData initValue) { // b is a different pointer than initValue // but they both point to the same object. // So, changing b.BoolData will change initValue.BoolData b = initValue; // Change the value of b.BoolData to false Test(); } private void Test() { b.BoolData = false; } } -Nerseus
-
Whoops - forgot to answer the "big" question. Basically, you can't have two references to a value type. When you try and "point" a second variable to the object, boxed or not, you'll only get a copy. Now you *might* be able to do something if you allowed unmanaged code and created a pointer to your variable. I'm not sure if that's worth the effort though. Maybe if you explained what it was you were attempting to do, functionally, we could offer some help? -nerseus
-
I'm guessing that mioBool is a class? When you assign a variable to a class you are only copying the pointer. As you saw, changing a property using either variable means you're changing the same data. When you do the assignment you ONLY copy the pointer - not the object itself. When you do an assignment on a struct or a value type (like bool, int, string, etc.) it makes a copy of the object. So B now points to a new version of the object. It doesn't matter if the values are boxed or not. The boxing only allows you to pass the bool to functions that take an "object" as a parameter. It also allows you to do things like call "ToString()" on an int. nerseus
-
What object is it? If it's yours, why not just use a struct? -Nerseus
-
I'd suggest getting port 443 open in addition to 80. If you plan on using webservices AND you want it secure, then you're looking at SSL which usually uses port 443 (I think). I'd say "use .NET and SQL Server" but that's a given :) If you want details, that would mean multiple architecture documents describing network communication, server setups, etc. -ner
-
How To Transfer Data From One Database To Other ?
Nerseus replied to vinidel's topic in Database / XML / Reporting
Do you really need a copy, or can you use Access's linked tables (or whatever they call them)? Can you use Access to import the data? What about another tool? If you must do it manually, through code, I'd use a DataReader to Oracle and direct INSERT calls to Access. But unless you really need to do some data manipulation that requires custom code, I'd try to use any existing bulk copy methods you can (as mentioned above). -ner -
You can use: textBox1.Undo(); or textBox1.Undo() For the record, it's probably easier to make your own menu from scratch. I suppose you could try and subclass the window itself with a LOT of work and add your own menu items. But creating the new menu yourself in an hour or two seems easier. -Nerseus
-
You can create a connection and keep it around for the life of your app. As for each call, you can use a DataAdapter to get a dataset locally and work with it. A DataSet has NOTHING about about a Database associated with it. You can also use a DataReader, which is basically a client side cursor. The datareader holds a connection as long as it's open. Which you use, as Robby was asking, is up to you and what you want. If you only have one user talking to your Access database, you might as well open the connection and leave it open - easier to code and no performance issues since you're the only one. If there are multiple users to one Access DB, you might still want a persistent connection - depends on how many users and other factors. Regardless of the connection staying open or closing, you can still use a DataAdapter to fill a DataSet. A DataSet is like a very simple in-memory database filled with tables, relationships and data. You can bind to a DataSet if you want, too. When you're done modify the data in a DataSet and want to save it, you go through the DataAdapter again to have it update the database. As I said above, a DataSet is database-agnostic - it knows nothing of the underlying database. That's the job of the DataAdapter. -ner
-
There's a known issue with a Picture box loading pictures directly from disk - basically it holds onto that image. You can test this by loading a picture from disk into a picturebox using the load method then trying to overwrite that image on disk (you can't). I think the workaround was to load the picture into an Image, then load the Image object into a Bitmap and assign that bitmap to the picturebox's image property. Then you can dispose of the Image and the PictureBox will cleanup after itself. -Nerseus
-
Assuming you have your dependencies setup (project A depends on project B) then compiling/running A should detect a change in project B. If it doesn't, it might not copy over the new DLL (to the bin\debug folder) every time. I've had the best luck with a full rebuild when using multi-project solutions. Assuming project A's reference to project B says "copy local", everything should be fine (copy local is the default - it copies the compiled DLL to the bin\Debug folder). -Nerseus
-
You can still pin memory and get a pointer to any managed object BUT to use copymemory you would have to know how big a chunk to copy. I think that's what wyrd is looking for. If it's a simple class, you could try and "guess", but I because of byte alignment I don't know if there's any guarantee that your program won't change on a different platform (when 64bit computers are more normal for instance). Tough call. -ner
-
So you get this with a default install and then a new project with no modifications? Maybe give us the exact steps you took to get this error. Also, I wouldn't "bump" a post so soon. It's in bad taste if you haven't waited at least a couple of days and might keep some otherwise helpful users from posting. -ner
-
I no of no way to get the size of a managed class. Here's a blog from Microsoft that talks about this topic though - it might be helpful (I didn't read it through): http://blogs.msdn.com/cbrumme/archive/2003/04/15/51326.aspx Here's an article about memory, might also yield some results though again, I haven't read it: http://www.albahari.com/value%20vs%20reference%20types.html -ner
-
While a decimal CAN hold very large numbers, he might not get the precision. Meaning, though you can hold numbers with essentially 20 decimals, it might not work for what he wants. If your whole plan is to calculate a square root manually, then you don't want a numeric type at all - wouldn't that defeat the purpose of learning how to calculate the square root if the built in Math functions do it for you? If this is for a learning excersize, or if you just really need this functionality, I'd suggest creating your own class - maybe BigDecimal. Whether you store the final result in a string or array is up to you. By the way, this is a common problem brought up in College courses - if you just want to see how it's done, I'm sure you can search Google and find some code in existence that will give you the base for what you need/want. It will probably be in C++, but I'm sure you could convert it. -nerseus
-
Problem passing parameter to crystal report
Nerseus replied to jccorner's topic in Database / XML / Reporting
I'm guessing you have the name wrong? Otherwise Crystal should not be prompting you. If that's not it, maybe Crystal has an option to "always prompt for params" or the reverse, and it needs to be set/cleared? -ner -
What does it take to cause a DataSet to "Have Changes"?
Nerseus replied to Denaes's topic in Database / XML / Reporting
If you're not explicitly starting an "edit", you shouldn't have to end one. Maybe you're calling AcceptChanges at some point? That clears all the changes in the DataSet and should only be called after committing the changes. -Nerseus -
I wouldn't imagine you'd want either of the "const" keywords on your definition of getCount. Just make it: int Tool::getCount() { return toolCount; } -nerseus
-
I should mention something - DirectX is a LOW level API, for the most part. It does provide some "high" level functionality for things like meshes and drawing lines (as opposed to drawing a line yourself, one pixel at a time). For the most part, you're looking at a LOT of work to get the 4 items you mentioned. Setting up DirectX can be a pain in its own right - easier if you know the hardware you'll be running on. Building a heightmap can be done, but unless you find some already written code, you're looking at custom code at locking a surface to read the color bits (as mentioned), then building up a triangle list yourself to fake the heights of each vertex on your heightfield. Moving around in 3D can take a bit of code as well. Look at even the simplest "interactive" 3D samples and you'll see a couple of screens full of code. Meaning, there's no "move camera left, move camera right" kind of functionality. Everything will have to be done by multiplying matrices to move around. Again, DirectX is fairly low level in this regard. Have the camera track against a path is going to be the hardest part, in my opinion. It will involve the most math to get the camera to follow the path and, potentially, change orientation to "watch" some point on the screen. I'm not trying to discourage you - just giving you a heads up on what's involved with using DirectX by itself. Trust me, if you can get a textured cube just spinning on the screen, you'll jump for joy :) Having said that, there are lots of free libraries and, I'm sure, some cheap commercial ones that might make your life easier. I'd spend some time investigating what's out there that might help you create a heightfield or move the camera. If nothing else, precreate the heightfield in some 3D application (Milkshape is only $20) and export as a .X file and just read that in. -nerseus
-
I'd second Plausably's solution. If you just used the same named method names in each class, but not through an interface, then you lose the ability to cast an instnace of your control to the interface and call one of your new methods. Obviously that's only a benefit if you need that functionality, but I would think you would want it at some point. -ner
-
I searched google for "C# java" and got this: http://genamics.com/developer/csharp_comparative.htm I'm sure there's more, maybe better/maybe worse. -Nerseus
-
Why SQL can't group by Text???
Nerseus replied to georgepatotk's topic in Database / XML / Reporting
Why do you even need InvoiceNumber in that query? It looks like you're grouping by only two fields and just getting a count? Even if you wanted to ues "... COUNT(DISTINCT InvoiceNumber)", you still wouldn't need the InvoiceNumber in the GROUP BY. -nerseus -
I can't speak on MSDE's performance directly. But for Access (which I haven't used in a few years), I never got horrible performance, even with 3 or 4 users at once. Are you sure it's all in the connectivity and not in the queries themselves? You don't HAVE to switch DB providers if you don't want to. If you moved to MSDE you probably would want to though, for performance reasons (the sql provider is made for MSDE/SQL Server). You'll always get better performance out of hard-coded connection (is that what you mean by bound?) vs creating the connection each time. However, I wouldn't think the performance would be that noticible with such few users. At least for MSDE, the connections are usually kept alive on the same machine for 3 minutes (the default, I think). In access you can create a linked table to MSDE. If you moved the data to MSDE, this is the route I'd probably go with. You could also import the data into Access if you needed to, but I think a linked table is what you'd want. -n
-
Ah, you said you wanted a combined total per the date - not separate totals. If it were me, I'd use some temp tables. They're easy to use and understand, especially for reports that often need misc data grouped together. There's likely a way to do do it one select, but I'm too lazy to think about it right now. Also, temp tables can often be faster since you can avoid a bunch of joins to get what you want. I'm If you use SQL Server, something like this: CREATE TABLE #temp2 (MyDate datetime, Amount2 money) CREATE TABLE #temp (MyDate datetime, Amount1 money, Amount2 money) INSERT INTO #temp (MyDate, Amount1) SELECT [date], sum([Amount]) FROM Table2 GROUP BY [date] INSERT INTO #temp2 (MyDate, Amount2) SELECT [date], sum([Amount]) FROM Table3 GROUP BY [date] UPDATE #temp SET Amount2 = #temp2.Amount2 FROM #temp2 WHERE #temp.MyDate = #temp2.MyDate INSERT INTO #temp (MyDate, Amount2) SELECT #temp2.MyDate, #temp2.Amount2 FROM #temp2 WHERE NOT EXISTS (select * from #temp where #temp.MyDate = #temp2.MyDate) SELECT * FROM #temp drop table #temp drop table #temp2 -ner