|
You can use classes from System.Data namespace and build the database only on the client. You would have DataSet, DataTable, DataView, constraints etc. Moreover you could serialize the data and read them when App start. Advantage: you work with database without any DB engine .
Tomas Rampas
------------------------------
gedas CR s.r.o.
System analyst, MCP
TGM 840,
293 01 Mlada Boleslav,
Czech Republic
Telefon/phone +420(326)711411
Telefax/fax +420(326)711420
rampas@gedas.cz
http://www.gedas.com/
------------------------------
To be or not to be is true...
George Bool
|
|
|
|
|
Why not use MSDE? I'm not sure if this qualifies as an "external database". If you're looking at using mysql you're using an external database anyway.
I really wouldn't go and reinvent the wheel though.
|
|
|
|
|
Sorry I didnt make this clearer in my original post. The particular flavor of mysql I was looking at is an embeded version that runs inside your application. You use their dll to interact with the database files. There is no 'external process'.
What I am looking for is a solution that the user wont have to muck with. I want them to run my application, and that is it. I dont want them to have to start a database server first. Think Outlook Express.
Thanks for the feedback, I will look into MSDE (not all that familiar with MS technologies).
|
|
|
|
|
Internally, I'd work with DataSets and DataTables, no question. Because both MSDE and Access databases have quite expensive disk costs, I'd use the XML serialization features in conjunction with compression (SharpZipLib perhaps?) to persist these structures to disk.
Here comes the clue: You can use the DPAPI (Data Protection API; look for CryptProtectData in MSDN) to encrypt them without worrying about key/password management.
|
|
|
|
|
For compression you could also check out the J# libraries. They have built in Zip compression.
-Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
But do you need to ship a separate j# redistributable
Kannan
|
|
|
|
|
yeah, that is a down side...
But with the app I am working on, it is a small thing compared to the rest (DirectX 9, MSDE, Framework 1.1)... so hell why not
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Forgive me if I am saying something that doesn't make sensen as I am not familiar with DataSets and tables... The amount of data I will be working with will typically be around 100mb (maybe 10k rows). If DataSets and DataTables keep everything in memory without using disk this would give my application took big of a memory footprint (although the access speed would be nice =) ). Also, I would be concerned with the amount of time it would take to serialize and compress the XML, then on load bring it all back in.
A similar application to what I would like is Outlook Express. Potentially the user could have 3 years of email in several folders. In order to access their data all they do is run Outlook, they dont need to start an external database server of any kind... and the memory footprint is reasonable even if you have 10k email messages.
Thanks for the incite, I will definitly look into DataSets and tables more to see what they are all about. It should definitly come in handy some day.
|
|
|
|
|
Customer singleCustomer = new Customer();
PropertyManager pm = this.BindingContext[singleCustomer] as PropertyManager;
What does the as keyword do here is it the same as type casting with the parentheses?
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
What does the as keyword do here is it the same as type casting with the parentheses?
The basic idea is the "as" keyword does the same thing as casting except if the object can't be cast it won't throw an error, it will return null so you might want to do something like:
Customer singleCustomer = new Customer();
PropertyManager pm = this.BindingContext[singleCustomer] as PropertyManager;
if(pm != null)
-Nick Parker
|
|
|
|
|
So is that bad programming practice and should only be used in strictly sure cases or it doesnt really matter?
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
So is that bad programming practice and should only be used in strictly sure cases or it doesnt really matter?
There isn't a problem with it as long as you are confirming the cast was performed without returning a null value. If you don't check for a null value and the cast returns a null, accessing your object will then throw a NullReferenceException .
-Nick Parker
|
|
|
|
|
There are somethings we are bound to miss, but I have a hard time beleiving, I missed this one. Did not pay attention to the usefulness of "AS"...
Tanx!
Rocky Moore <><
|
|
|
|
|
-Nick Parker
|
|
|
|
|
Well, if your research patterns are anything like mine, you mainly concentrated on the things things that you needed to get the job done, and therefore skipped some of the extras, like this one.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
jdunlap wrote:
Well, if your research patterns are anything like mine, you mainly concentrated on the things things that you needed to get the job done, and therefore skipped some of the extras, like this one.
Just remember, it all maybe useful sometime down the road, mental bookmarks do it for me.
-Nick Parker
|
|
|
|
|
Yes.
Speaking of research patterns:
What I find best is to investigate the technologies you come across just enough to get a feel for what they do and what they would be good for. Then learn in detail the technologies relative to the projects you work on. If you happen to need a certain functionality, your "shallow research" will have given you the knowledge you need to narrow down your search to the technologies that will fit the new need.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Well I kind of like the as even though it resembles vb code. I'm used to type casting in c++ where I constantly check for null values but I would much rather throw an exception.
But then again exceptions in .NET are very costly and therefore as would work better.
But then again if your not using reflection you should know what the object was and it would be easier to test for null.
I guess would say the () is better in that it throws an exception unless it is a popular function in that case I would use as to keep it running fast.
My opinion, critices and comments welcome
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
I guess would say the () is better in that it throws an exception unless it is a popular function in that case I would use as to keep it running fast.
Umm, the last part of your sentence does not make any sense, care to elaborate? Casting using "as" will not allow your code to run faster than standard casting mechanisms between types, if standard casting fails it will throw a InvalidCastException . If an "as" cast fails returning null and you access a method or property to your null object you will get a NullReferenceException .
-Nick Parker
|
|
|
|
|
Well I guess I was misunderstanding in that I thought it would just return null instead of a casting exception.
doh!
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
I use as when its possible for some object to not be castable to the type I want.
For example:
private void MyEventHandler(object sender, EventArgs e)
{
ToolBarButton b = sender as Button;
MenuItem mi = sender as MenuItem;
if( b != null )
{
}
else if( mi != null )
{
}
} You would so something like this where the same event handler is used for two different events. In this case standard behavior dictates (at least it used to) that when you click the Print button on the toolbar you don't show the Print dialog box. While clicking the Print command in the menu you should display the Print dialog box.
Unfortunately my example has one slight flaw, the way the ToolBar control works makes it hard to use my example. I still chose to use that example because it is something we should be familiar with.
You should use a cast when you don't expect the cast to fail (an exceptional condition calls for an exception to be thrown).
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
Okay so I am now totally confused
Nick said if it cant cast to that type I get a cast exception.
James says if it cant cast it just returns null.
Well i guess I'll just test it myself, but in theory:
C++:
if cast to something thats not castable I get a null value(0), which is sweet
then i just do an if an can ignore the horrible exception delay
but if i cant I dont see what the difference is rather than code taste
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
Nick said if it cant cast to that type I get a cast exception.
James says if it cant cast it just returns null
I think you are confusing the two methods of casting we are talking about here. If you do something like:
Object o = new Something();
Something s = (Something)o;
and your cast fail, it will throw an InvalidCastException (Assuming Something is derived from Object ). However if we are talking about an "as" casting and you doing something like:
Object o = new Object();
Something s = o as Something();
if(s != null)
{
}
Failing to check if s is not equal to null and trying to access a member of s would throw an NullReferenceException if the cast for s was returned as null.
-Nick Parker
|
|
|
|
|
I think it was the fact that I misunderstand or bypassed some of your answer.
I have a bad habit of checking for null after I cast from the MFC days.
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
If the successful typecast is crucial in performing the function, go ahead and use var = (type) object; . If, however, there are alternate ways of performing the function, the as keyword is often better; even if you throw an exception anyway, because catching and rethrowing an exception is very expensive.
void Function()
{
try
{
IReferenceService refSvc = (IReferenceService) GetService(typeof(IReferenceService));
}
catch (Exception exc)
{
throw new UsefulException(message, exc);
}
}
void Function()
{
IReferenceService refSvc = GetService(typeof(IReferenceService)) as IReferenceService;
if (refSvc == null)
{
throw new UsefulException(message);
}
}
|
|
|
|