|
Dear all,
I am developing a desktop application in c# with sqlserver2000, presently my application is doing following steps to communicate with database.
1. Open the connection
2. Create a command
3. Define the input parameter
3. ExecuteNonQuery
4. Assign new values to input parameters
5. ExecuteNonQuery
6 Close Connection
I need help in this regard, is this best practise regarding desktop applications or not.
what about below option?
that i build sql connection and put it in some public object in some class and next time use this global connection object.
infact i would like to imporve my application speed.
Thanks and regards
Muhammad Sarfraz
|
|
|
|
|
I prefer the scenario you described. Just because you benefits from framework built-in connection pooling. You don't need global objects, but remeber for each openning connection you MUST provide the same connection string (means equality of content).
For more (and better described;P) details see MSDN documentation or online
http://msdn.microsoft.com/vstudio/using/understand/data/default.aspx?pull=/library/en-us/dnadonet/html/adonetbest.asp[^]
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
|
|
|
|
|
dear Tomas Rampas thanks for help
my first option in which i open and close connection, i feel would be slow because each time i am opening connection for same sort of things.
i have heard from some where that open and close connection is best for web applications and where as for desktop applications you can hold connection object at application level. What u say, i am yet confused(
thanks again for help .
Muhammad Sarfraz
|
|
|
|
|
Hello Gurus,
I use public/shared connection at Form level for my desktop application. Especially, when you frequently create and destroy connections, performance woud be improved dramatically.
One note: you have to close an OleDbDataReader before it lets you reusing the same connection.
Khang Nguyen
|
|
|
|
|
Is there a simple method within the .NET framework to check for Internet network access without it popping up a dialer box for those with dial up?
I want to make notification application that runs in the background and checks for notifcations every 15 minutes or so, when they are connected. If there are not connected it will sit idle waiting until they do.
Any ideas?
Rocky Moore <><
|
|
|
|
|
No there is not, fortunately you could use interop and InternetGetConnectedState Win32API function.
(code adopted from someone within MS)
<br />
bool IsConnecting;<br />
<br />
[DllImport("wininet.dll", SetLastError=true)]<br />
private static extern bool InternetGetConnectedState(ref UInt32 Flags, <br />
UInt32 Reserved);<br />
<br />
private void buttonStartMonitor_Click(object sender, System.EventArgs e)<br />
{<br />
UInt32 Flags = new UInt32();<br />
IsConnecting = InternetGetConnectedState(ref Flags,0);<br />
timer1.Interval = 100;<br />
timer1.Start();<br />
}<br />
<br />
private void timer1_Tick(object sender, System.EventArgs e)<br />
{<br />
UInt32 Flags = new UInt32();<br />
if(IsConnecting != InternetGetConnectedState(ref Flags,0))<br />
{<br />
IsConnecting = InternetGetConnectedState(ref Flags,0);<br />
}<br />
}<br />
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
|
|
|
|
|
Thanks, I knew the Win32 method, just looking for a .NET only solution.
Rocky Moore <><
|
|
|
|
|
Yeah, you'd think there would be one, especially with .NET's emphasis on the internet. But the WinAPI way is not hard at all.
"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:
Yeah, you'd think there would be one, especially with .NET's emphasis on the internet.
Yeah, you would think so, but I just remember this is only version 1. I figure they will get it in there within the next version or two.
jdunlap wrote:
But the WinAPI way is not hard at all.
No, not hard, just not portable. I hate to rely on Win32 calls unless there is absolutely no other way and the feature must be supported. I would rather not implement some features if it requires going to Win32. It is not that .NET works on many different platforms yet, but I do not want to go back and make all kinds of changes in the future if at all possible. I know one day the code will be going cross platform and want to be prepared.
This next winter I plan to invest some time into the Mono/Linux platform and see just how much can make it with with they have at the time. You never know when Home Land Security will label Windows a virus
Rocky Moore <><
|
|
|
|
|
Rocky Moore wrote:
No, not hard, just not portable. I hate to rely on Win32 calls unless there is absolutely no other way and the feature must be supported. I would rather not implement some features if it requires going to Win32. It is not that .NET works on many different platforms yet, but I do not want to go back and make all kinds of changes in the future if at all possible. I know one day the code will be going cross platform and want to be prepared.
Exactly. One way to do it, though, is wrap the functionality up in a wrapper class, and write one for each platform. But if there's a .NET implementation, that's much, much better.
Rocky Moore wrote:
This next winter I plan to invest some time into the Mono/Linux platform and see just how much can make it with with they have at the time.
I'd be interested to know how it goes.
Rocky Moore wrote:
You never know when Home Land Security will label Windows a virus
"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:
Rocky Moore wrote:
This next winter I plan to invest some time into the Mono/Linux platform and see just how much can make it with with they have at the time.
I'd be interested to know how it goes.
Yeah, it should be interesting. Have been keeping up with their progress but still have to find the time to dig in and see how much is really working along with how I like writing Linux programs
Rocky Moore <><
|
|
|
|
|
Hi everybody.
I posted a question here yesterday regarding the intricacies of the ECMA CLI standard, and how to determine the number of bytes you should read for a particular metadata table.
Zoiks, sounds exciting eh? You bet. If anyone has any interest in reading .NET dlls,or any knowledge of Partition 2 of the CLI standards, please check out my question as you may be able to help.
Much appreciated, thanks.
Jason King
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
Heh, just realised I should have posted this on the .NET discussion page.
Please don't flame me, please don't flame me!
Jason King
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
I won't. If you post a programming question in the Lounge, that's when you'll get flamed big time.
"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
|
|
|
|
|
Profox Jase wrote:
Heh, just realised I should have posted this on the .NET discussion page.
Please don't flame me, please don't flame me!
I wouldn't worry about it, perhaps if I were more diligent in the early days of this forum your post would be off-topic. Alas, I answered any .NET question here so it got used more than the .NET forum
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
|
|
|
|
|
Thanks boys an girls, for not hammering me. If any of you have any spare time, please do have a look at the question - I guess its one of those things that you either know, or you don't care, or you want a challenge.
Well, I guess I am trying to manipulate you into solving my problem for me. There is just one piece of logic I can't figure out - Ben Peterson's Asmex code is a winner, just I am too dumb to figure out one last crucial element.
Jason King
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
|
|
I am creating a windows application using c# and have the need for a robust data store. My application is similar to that of Outlook (different data, similar size + display) where the listbox that contains your mail items can have upwards of 10k entries and 100mb+ of data. I am researching different methods of storing this data so that the application can have easy access to it (not only for displaying but also random access and searching). Storing the data in an external database is not an option. The data store must be internal to the application (atleast from the user's point of view).
I remember something about Outlook using a striped down version of sql server on the inside... I have looked a little into using embeded mysql server and I have seen a few people talking about doing the same. Can anyone provide feedback weather or not this is a good idea? Are there better alternatives for a data store that can handle this quantity of data effeciently?
Thanks.
|
|
|
|
|
Have you considered using MS Access.
You dont have to install anything spl(drivers et al) for accessing them also you can password protect the db, I know CityDesk[^](a content mgmt. system) uses them extensively.
Regards,
Kannan
|
|
|
|
|
I have considered using an external database but realized it just isnt an option. I dont want the user to be required to run an external service just to use my application. They should be able to run it, and it alone, and have it display their data. Think Outlook Express and large quantities of email.
Thanks.
|
|
|
|
|
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.
|
|
|
|