|
I am currently (again) updating a database application that I wrote last summer. I need to add a new feature....
This brought one big question to me: Is there now way of making my database loading smarter??? Like loading it all once in one place and link all things to that one place??
Well, here it is the question: Anyone having any idea if it is possible to load the database once and use it anywhere in the application? This should reduce the amount of memory needed by the application to run. Since information like "members" and so on will only be in memory in one place instead of the six places at this very moment.
(I ran out of virtual memory, and that's a bad thing )
Greetings....
|
|
|
|
|
The tradeoff really depends on what you're doing. If you're going to be touching all the data often, loading it all in can be good. If you only touch a fraction of the data, then loading it is probably bad.
You may want to look at your database structure to see if you can make it more effective.
|
|
|
|
|
The data in the database is used very often and is mostly combined in one view.
My idea is to make a class the holds all the methods for editing and viewing the data
in the database. Then I need to make one static instance in the main class of my program, so I can access it from all the other forms and classes.
I use DataAdapters and DataSets to display all the data, I guess there's no other way than loading the whole table that's managed with the dataAdapter.
Maybe someone does have another idea for loading the data?
Greetings....
|
|
|
|
|
I've used the approach that you're thinking of with some reasonable success (but remember that I'm a Microsoft PM, and therefore, by definition, never write any *real code). Having it central has made things quite a bit easier, and allowed me to centralize things like caching.
My personal preference is not to use DataAdapters and DataSets when I take this approach, and write routines that look like:
public List<t> GetValues<t> (string selectStatement)
{
OleDbCommand select = new OleDbCommand (selectStatement, connection);
List<t> list = new List<t> ();
OleDbDataReader reader = select.ExecuteReader ();
while (reader.Read ())
{
list.Add ((T)reader[0]);
}
return list;
}
This is a version using Whidbey generics, but you get the idea. For me, this is much simpler to code and understand than using the built-in data support in VS. Of course, I spent 3 years working for a database company (SQL is my friend...), so your mileage may vary.
|
|
|
|
|
That's a good solution for reading only those values you need
I think I'm going to use that one instead of the large amounts of dataAdapters.
Greetings....
|
|
|
|
|
I want to create a setup project for my application.I add a installer class to do some custom actionns after install.(Add my application to ngen.exe),so I need the path of my installed application.How can I get it in installer class.Any idea?
Mazy
No sig. available now.
|
|
|
|
|
If I'm correct, you can try Application.Startup or somethun..
This by our hands that dream,
"I shall find a way or make one!"
|
|
|
|
|
I was wondering if you figured this out as i have the same problem
|
|
|
|
|
NOt the exact answer but this return the path of helper assmebly which the think that we want:
this.Context.Parameters["assemblypath"]
Mazy
No sig. available now.
|
|
|
|
|
There is Timeout WebException occurs at the 'stream.Read' of following codes.
Process hangs after reading a few times.
Why?
(Visual Sudio.net 2003, .Net Framework 1.1, Windows XP Professional sp1)
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://download.adobe.com/pub
/adobe/acrobatreader/win/5.x/5.1/AcroReader51_KOR.exe");
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
FileStream fs = new FileStream("AcroReader51_KOR.exe", FileMode.Create);
long currSizeForThisFile = 0;
const int LENGTH = 1024;
const int OFFSET = 0;
byte[] buffer = new byte[LENGTH];
while (true)
{
/* Timeout WebException occurs after a few reading */
int rcvd = stream.Read(buffer, OFFSET, LENGTH);
if (rcvd > 0 && !enableExit)
{
fs.Write(buffer, 0, rcvd);
}
else
{
fs.Close();
stream.Close();
resp.Close();
System.Threading.Thread.Sleep(50);
break;
}
}
|
|
|
|
|
Hello, I posted a similar msg earlier and I am writing a print command in an application. All it does, is to print out a document with some headers and footers. So, I used a simple way to printout headers and footers. However, I still cannot keep track of the page numbers when I print out a document. I looked up the properties of printdocument, pagesetupdialog and printpreviewdialog, but I couldn't find any 'related' property. I also tried to keep track of page numbers in my print function (a loop to Graphics.DataString(...), but failed.
Can anyone please give me some ideas? Thanks so much!!
|
|
|
|
|
I wrote an app where I could track the page number on a very easy way.
Declare for the full app
private int page = 1;
At the end (last line) of your printDocument_PrintPage class add
++page
in your PaintDocument class just use this.page
The PaintDocument class is called from the printDocument_PrintPage class just to split up the drawing of the page in another class.
|
|
|
|
|
Thanks! That page number problem is solved.
I am now trying to get the total number of pages.
|
|
|
|
|
Oh, I solved the total page number problem too. Great!
|
|
|
|
|
I want to set the state of a button. I am trying to make a button appear to be pushed. How do I do that?
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
I don't think, that there is simple way to do this, but you can use SendMessage API function to send WM_LBUTTONDOWN message to button. It will appear pushed until you send WM_LBUTTONUP message to it (or until user does something with this button). This will also raise OnClick event.
|
|
|
|
|
Thanks. I am handling the click event, so I don't think what you suggested will work in my case. I want the button to stay pushed in response to a click event. I am an MFC developer who is giving C#.Net a try. This would have been easy in MFC. Why does .Net make simple things so hard?
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
Use a checkbox and set its Appearance property to Button. I'm glad MS did that - it really is better than having a different control, becuase the behavior of the toggle button is the same as the checkbox, so why not have them be different Appearances of the same control?
|
|
|
|
|
Thanks, I knew suspected hoped there was some easy way of doing it.
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
Regards,
Is it possible to set a form (container)'s transparency independent of its child components and controls??
I mean if I set Form's opaque to 50% all controls get 50% opaque too while I want them still at 100%
any guid may help and is appreciated.
Thanks
-nSun
---
"Art happens when you least expect it"
|
|
|
|
|
As far as I remember, the Opacity property is declared within the Form class itself, not anything more generic. Thus, I can see 2 options:
1. Make a seperate embedded form for your controls (although I'm not sure this would work)
2. Override the paint handler for each control.
Of course, I could be wrong....
Jeremy Kimball
|
|
|
|
|
Thanks for the reply.
any other idea?
---
"Art happens when you least expect it"
|
|
|
|
|
Hi,
Having not found a good XPath tutorial out there yet, here is my question..
This is how I try to display the fisrtname of the first contact in the Contact.xml file,
Consider this code:
XmlDocument myDoc = new XmlDocument();<br />
myDoc.Load(Application.StartupPath + "\\Contact.xml");<br />
txtPrénom.Text = myDoc.SelectSingleNode("//Prenom").Value;
What am I missing here?
Thank you for your help!
Antoine
This by our hands that dream,
"I shall find a way or make one!"
|
|
|
|
|
try
txtPrénom.Text = myDoc.SelectSingleNode("//Prenom[first()]").Value;
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
SelectSingleNode returns first node matching XPath so your code should IMHO work, but only if "Prenom " is element (not attribute). To select attrbute you need to use this XPath //@Prenom . You can also use xpath like following:
Xml:
<contacts>
<contact firstname="Bill">
...
<contact>
...
</contacts>
<br /><br />
XPath: <code>contacts/contact/@firstname</code> returns 'Bill'
Great XPath tutorial is at www.w3schools.com[^].
|
|
|
|