|
Software2007 wrote: am i missing something here?
Big style. It's called scalability. Database connections are expensive resources, and should be treated as precious resources.
Software2007 wrote: But, I don't like to open it up every time I query the db
So, laziness is a virtue in your world?
Software2007 wrote: In my main program in C#, I can open a connection to postgresdb , do some queries and close connection afterwards.
Is it a desktop application? If it's a web application then you can't do this anyway, so you might as well get used to the idea of acquiring the connection at the last minute and releasing it as soon as possible.
Here's a poser for you. Suppose you open your connection at the start of your application and your code relies on this connection being open. Now, suppose that the database crashes and restarts between you querying it. What do you think will happen the next time you issue a query? If you guessed that the code will fail, go to the top of the class. If you think you can rely on the connection always being available, slap yourself around the head with a pink halibut and call yourself Ethel.
|
|
|
|
|
Good answers. I knew the whole costly issue and the concequences of crashing while executing, but I was hoping that I was wrong and there was a more efficient way.
|
|
|
|
|
Write yourself a wrapper class that opens up the connection for you when you execute your SQL if you're worried about remembering to do this.
|
|
|
|
|
Thanks, but, No, I'll just try to suffer like the rest of us.
|
|
|
|
|
To clarify more (I hope); you can hold the Connection instance for the duration of your application, but only open it when you need it then close it. That's what I do, even with Windows Services that run 7x24 forever. And also use connection pooling.
It's really very easy, if you think it's difficult then you must be doing it wrong. You can check out this fine article[^], or use a DataAdapter (which I don't recommend).
|
|
|
|
|
I am trying to rename a file with File.Move() method. I get an exception on my File.Move() code. the exception is like "The file is already exists|r\n"
I have checked if the file exists or not. The file exists.
string fileToRenamePath = RMAConfig.PDFPath + this.rmaObjSum.RMANum + RMAConfig.Extension;
string fileRenamedPath = RMAConfig.PDFPath + "[Return Documentation" + rmaObjSum.RMANum + "]" + RMAConfig.Extension;
File.Move(fileToRenamePath, fileRenamedPath);
I worked it around instead of using File.Move() method;
I have used:
File.Copy(fileToRenamePath, fileRenamedPath);
File.Delete(fileToRenamePath);
But i am curious why did i get an exception while i was trying to rename the file by using the File.Move() method.
|
|
|
|
|
"The file already exists" means that the filename you're trying to rename the file TO already exists, not the file your renaming.
|
|
|
|
|
oh yeah you are right, carelessness.
|
|
|
|
|
Hi All, I need to display my assembly version on about form. I am not quite sure how get it and display on a label. if know please let me know.
thaks,
|
|
|
|
|
Google says...
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
...you can determine the version of your application in the AssemblyInfo.cs file which may be found in the Properties folder of your solution (VS 2010)
EDIT: Slight correction of Google found code
Illogical thoughts make me ill
|
|
|
|
|
Thanks for your reply. I already have gotten it, google is the best friends of mine since I started programming. I still don't get it why I am getting asm version
1.0.0.0 where I see is 1.0.7. I have a installer what does it means project and installer will have two different assembly version.
thanks,
|
|
|
|
|
In your solution you will find a file called AssemblyInfo.cs in the properties folder. This file will contain an "AssemblyVersion" property which determines the actual version of the assembly (this will be the value you get if you use my suggested code)
I don't use VS for installers but I imagine the installer version is simply there as a sort of "release version" value - i.e. it is up to you to pick this, and would probably make sense for you to set it the same as your assembly version (this paragraph is speculation as I said I do not use VS installer wizard thingy)
e.g. you may choose to have the following...
Assembly Version = 1.2.3.4
Installer Version = 1.2 (don't need to show the rest is you only ever release minor build changes)
Illogical thoughts make me ill
|
|
|
|
|
You can get the version for the application with Application.ProductVersion[^].
For an individual assembly you can use something like
Assembly.GetExecutingAssembly().GetName().Version
which may, or may not give the same result as the first suggestion.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
The are two version properties in the AssemblyInfo.cs file...
AssemblyVersion - which is returned by your second suggestion (code)
AssemblyFileVersion - which is returned by your first suggestion (link)
Illogical thoughts make me ill
|
|
|
|
|
Which may, or may not be the same, depending on how they have been set.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
...Oh I see, that was a statement of knowledge rather than of query
Illogical thoughts make me ill
|
|
|
|
|
See here[^] for sample code to extract the details.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi,
Can you let me know the sample to create xml file using SAX parser. Thanks in advance
|
|
|
|
|
You were told here[^] that .net doesn't use a SAX parser out the box. The equivalent is XmlReader , but this only reads. You can use XmlDocument , XmlWriter to write or you can directly serialize/deserialize and object. Which is easiest depends upon what is exactly needed.
|
|
|
|
|
I have an vs2008 Installation package, and i want to create a patch for it.
Please cand somebody help me out?
Thank you.
|
|
|
|
|
how i can find cd is readable and dvd is writable or not
and how reset these properties.
plz explain with example.
thanx ...............
|
|
|
|
|
Aisha sharma wrote: plz explain with example
...plz explain with question
Do you mean actual CD/DVD or Drives?
And what do you mean by 'reset these properties'?
Illogical thoughts make me ill
|
|
|
|
|
yes i want get information about actual cd and dvd e.i.
cd/dvd readable or writable
and want to give rights to user so that he can block
readOnly or writeOnly accesstypes
|
|
|
|
|
Hi there,
I've got a real annoying issue with an extremely simple .net application (C#, .net3.5).
What I have is a simple program (comparable to Hello World) which launches a thread to periodically read an xml file and stores some values into memory which are used by the main app thread. The main application thread just looks for mouse events on a traybar-icon which open a webbrowser with a specific url. That's it.
What the problem is, is that on my dev-machines and home computers the app runs nicely for hours/days straight. On my work-pc, the application seems to enter in a blocked state on the main execution thread or it enters a deadlock/filelock or something after a few minutes and stops responding and the process has to be killed via the taskmanager. This only happens on my work-machine which is Windows XP with .net4.0 installed. All other machines are also windows XP (any flavor) with .net3.5 installed. No error windows or logging present.
I'm at a total loss here. I ran through the code numerous times and checked all IO/Threading routines, but no loose ends found. Any ideas what it might be? Could it be the 4.0 runtime? (which I seriously doubt)
A good programmer is someone who always looks both ways before crossing a one-way street. (Doug Linder)
|
|
|
|
|
there is insufficient information.
is it a WinForm app? if so, is another thread trying to access some of the Controls?
do you have proper exception handling? are all exceptions caught and logged? are you swallowing some?
when it blocks, is the CPU load near zero? or rather near one fully occupied core?
Helfdane wrote: an extremely simple .net application
so why not show all relevant code?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|