|
As far as performance issues are concerned I have a question ....
I have to make multiple selects based on date inside of a loop.
Is it wise to use the USING statement for the datareader inside of the loop or does something need to be done outside the loop.
Here is my current code.
<br />
using (SQLCommand selectAnnv = new SQLCommand(_database)) {<br />
SQLParameter paramDate = new SQLParameter("@DATE");<br />
<br />
selectAnnv.CommandText = "SELECT id FROM " + TMEMBERS + " WHERE registered = '(@DATE)'";<br />
selectAnnv.Parameters.Add(paramDate);<br />
<br />
<br />
<br />
for (DateTime anniversary = lastHandled.AddDays(1); anniversary <= now; anniversary = anniversary.AddDays(1)) {<br />
paramDate.Value = GStatic.GetISO8601(anniversary);<br />
<br />
using (SQLDataReader readerAnnv = selectAnnv.ExecuteReader()) {<br />
while (readerAnnv.Read())<br />
ids.Add(readerAnnv.GetInt32(0));<br />
}<br />
<br />
}<br />
<br />
}<br />
Should the bolded/italic part be decalered outside of the loop?
|
|
|
|
|
BTW this is just an example there is actually a few more variables to read so ExecuteScalar does not apply
|
|
|
|
|
Why not just use a date range in your sql statement?
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
The engine does not support date type
|
|
|
|
|
Could you clarify that statement for me? You're using a SQLDataReader, so you're talking to a SQL Server.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
I'm sorry this is a custom DB much like SQLite, with even more limited types
|
|
|
|
|
hi all i want to save the word,html files in the database for my application.
i had two techniques
1.is save the path of files
2.is the save the whole text of file
can anybody tell me what will be best approach to do so. i shall be thankful to you.
Tasleem Arif
|
|
|
|
|
tasleem143 wrote: i want to save the word,html files in the database for my application.
i had two techniques
1.is save the path of files
2.is the save the whole text of file
can anybody tell me what will be best approach to do so
The first approach is not actually saving "files in the database", it is only putting in a reference to the file on the disk. If you are going to ensure that the file remains on disk then this approach will work.
The second approach is the only one to actually store the file in the database. So it is the only one that meets your requirements as you have explained them.
|
|
|
|
|
Which you chose depends on a lot of variables that is applicable to your specific project. Here are some thoughts that you might consider
1) Are the paths accessible by other applications [web server?] that might need them
2) Do the files have different backup requirements then the database? Maybe you might have a dedicated file server backup
3) Are there lots of reads and modifications? If so you might consider storing just the path if the files are extremely large, as this is the purpose of the file system.
4) Do you have to jump through permissions hoop to synch the application accessibility to your database and file server
5) Is the database and file server on two different machines? If so and your database server is under heavy loads, you might consider offloading some of the work to the file server. In this case though you have to keep in mind you might run through networking issues.
and list goes on and on...
|
|
|
|
|
1)NO
2)NO
3)Yes
4)i dont understand ur quesion
5)no these are on same machine
Tasleem Arif
|
|
|
|
|
Hello,
I'm trying to to the following thing:
<br />
<br />
public abstract class ITest<br />
{<br />
public abstract ITest(string val);
}<br />
<br />
<br />
public class Test : ITest<br />
{<br />
public Test(string val)
{
}<br />
}<br />
<br />
Is there any possibility for defining abstract constructors ? Interfaces can't define constructors. It's not important because I realized that it is not necessary, but nevertheless it's an interesting question.
thanks,
Florian
|
|
|
|
|
Abstract classes can't be initialized, and constructors can't be virtual => no need for constructors.
Abstract is a class-keyword...
|
|
|
|
|
You have an abstract CLASS called ITest, this is confusing. The convention is that interface names start with I[interface name], not class names.
If you do need to do some common work at construction time in the abstract class then use
protected ITest(string val)
{
}
Florian Storck wrote: Is there any possibility for defining abstract constructors ?
Yes, see above.
|
|
|
|
|
Hi Colin,
thanks for your answer. By the way: do you have a certain style for naming abstract classes (probably ATest, I guess ). I didn't changed the name because I'm used to C++ were abstract classes and interfaces are handled the same way (I do C# programming for basically 5 months now) ... so this difference in naming makes only really sense (for me), if the abstract class implements things, so it's not completely abstract anymore... but ok, C# has the interface type/definition, then it makes probably more sense.
Bye,
Florian
|
|
|
|
|
Florian Storck wrote: do you have a certain style for naming abstract classes (probably ATest, I guess ).
No, there is very little hungarian notation used in .NET. It is generally frowned upon. I for interface is one of the very few examples.
|
|
|
|
|
Can anybody help me with loading, diplaying and saving a bitmap file.
tony-yeyo
|
|
|
|
|
Image img = Image.FromFile("c:\\mybitmap.bmp")<br />
img.Save("C:\\mybitmap_copy.bmp")
for more information lookup the Image class in System.Drawing namespace
|
|
|
|
|
Hi All,
I am generating a set of datasets from few DataAdapters, and those generated datasets are referred in another project space as referenced dataset.
When i say
DataAdapter.Fill(datasetX, "tbl");
it does the task for me. The Memory size of the Exe in the runtime grows from 10mb to 20mb,but once i close the form the size never comes down. Even if i say
<br />
datasetX.Dispose();<br />
System.GC.Collect();<br />
And i was thinking of using 20 to 30 such datasets but will it not increase the size of my application ?
How can I bring down the runtime memory consumption ?
How can I Dispose the Dataset ?
Please help with this.
Thanks in advance
KSS
|
|
|
|
|
Are you disposing the connection object and DataAdapter object as well?
What happens when you open and dispose a bunch of datasets, does the memory size of the exe keep going up? System.GC.Collect(); is probably unnecessary.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Are you disposing the connection object and DataAdapter object as well?
No i am not disposing them , as they are dragged on to a component. and from that Adapter ->Right Click ->Generate Dataset.then i refer that dataset from my UI project.
What happens when you open and dispose a bunch of datasets, does the memory size of the exe keep going up?
No the size of the Exe remains the same.
how vital enterprise application are for proactive organizations <br>leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that <br>focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the <br>bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
This really is cool but High Level also...
Thanks for the answer.
KSS
|
|
|
|
|
Hi ,
anyone please help me how to make multiple scenorio in case. i tried with , operator but it gives error.
example,
switch(a)
{
case q,y:
...
}
|
|
|
|
|
try
switch(a)
{
case q:
case y:
{
ur calculations......(it should work for both case q and case y)
}
break;
...
}
rahul
|
|
|
|
|
You don't need the additional body! {} wastes some time and is often unnecessary. (I bet it pushes and pops the stack)
switch(a){
case q:
case y:
...
break;
}
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Hi.i have created application that has datagrid and texboxes.my application load data on datagrid on form load so i want display the same data on the texboxes,when ever i select a record on datagrid the the data on the texboxes must change according to the record.
|
|
|
|
|
Hello all,
How to get the size of reference type stucture,
ref Innerstruct
{
unsigned int j;
bool bl;
};
ref stuct sample
{
int i;
Byte b;
Innerstruct st;
};
sample s=gcnew sample;
int length=sizeof(s);
this returns 4, i thing it is the size of pointer. how to get the orginal size of structure and its members.
I posted it in C++, but didn't get reply if you know plz help
|
|
|
|