|
Thanks for the reply. I deliberately didn't include the code snippets because I tried so many. Indeed, I've used it before - the event handler is the only place that ev.HasMorePages is in scope (as an arg), unless I pass it on (which, in desperation, I tried at one point). So - yes, it's in the right location.
Whilst awaiting feedback, I continue my online search and came up with what might be an explanation consistent with the observed problems:
e->HasMorePages results in another call to the printDocument handler. I can visualize this (apparently) erratic behavior as being the the result of this call. I'm going brain-dead, shortly, but know exactly what I plan to do in the AM, which can be summed up as declaring a static counter for my data loop, printing a single records worth of data to the form, and if more data is available, setting e->HasMorePages to true. Resetting the static counter only after the entire loops been handled.
Unintended recursion.
Again, though, thanks. It's good to ask about the obvious before one goes to the subtle.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
I never had any problems with HasMorePages : when you call myPrintDocument.Print() , the system will fire a PrintPage event; your associated handler is where you must set PrintPageEventArgs.HasMorePages either true or false. As long as you don't set it false, the system will continue firing the PrintPage event. So you are not organizing the loop yourself, the system does it for you. You are responsible of course to provide the data that belongs to the page currently being printed, and normally the mechanism you need to achieve that is also what tells you whether more pages will be required or not.
FWIW: what I find more difficult to organize elegantly is the prediction of the number of pages the print job is going to require, this is the number you can provide to the PrintDialog in case you want to support partial page range printing. To get it right you either have to duplicate the paging logic, or somehow share it with the PrintPage handler itself.
|
|
|
|
|
Luc Pattyn wrote: As long as you don't set it false, the system will continue firing the PrintPage event
Thanks - this is the key: it's potentially recursive.
I'd just happened across a reference that said as much, which I posted. My plan is, as noted above, to use a static int as a counter (such as by giving it class scope), by which means it will (1) page and (2) not print everything on each page - or so I hope.
It's interesting that I've made this work for me in the past without understanding this simple but essential key to its use.
Thanks.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
You're welcome.
And yes, you need one or more variables that live outside the PrintPage handler, so they can remember how much your printing process already has handled.
|
|
|
|
|
Not sure if this is the right place for my question. I've got my new laptop, but preloaded with Windows 7 64 bit OS. As a developer, I got a question about the use of SDKs and other stuff on my new machine. For example, when I try SQLite download, they only provide packages for "x86-win32" platforms. Does x86 32 bit stuff works well on a x86 64 bit machine? Some explannation would be much appreciated. Thanks.
Best,
Jun
|
|
|
|
|
Yes, 32-bit code will run fine on Windows 64-bit.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
At the moment, all Intel/AMD based systems that support 64-bit also support 32-bit applications; same for Windows itself. So a 32-bit app will run just fine on any 64-bit system. Mind you, an app must be 32.64 homogeneous, you can't built an app that refers to both instruction sets; and that is where some trouble may originate: if you have a 32-bit DLL somewhere (say OLEDB to connect to Access), and some 64-bit DLL from some other source, you can't combine them into a single app.
If you build apps yourself, selecting "target=x86" on a 64-bit system should provide 100% probability the app will run on all 32-bit and all 64-bit systems. Unfortunately, Visual Studio defaults to "target=AnyCPU" which makes managed code run in 64-bit mode, and that would fail to load a 32-bit DLL later on.
|
|
|
|
|
It depends (as always). Most 32-bit apps will work fine on 64-bit systems, but you may bump up against occasional problems. One example I have run into is an application called TugZip, which is a file compression utility (c.f. WinZip, 7Zip, etc.). It installs and runs fine under 64-bit Windows but none of the shell extensions work. So, if you right-click on a .zip file in the Windows explorer, then none of the TugZip options show in the pop-up menu. I have seen various work-arounds suggested such as starting Windows explorer in 32-bit mode, but it's much easier to use another tool which integrates properly. They may have fixed it by now, I'm not saying TugZip is bad, wrong, or anything like that. I'm just using it as an example of a 32-bit app which doesn't quite work on a 64-bit platform.
|
|
|
|
|
That's a good example... I haven't seen too many things not work right. Usually if you have hardware drivers, those are the biggest headache with 64bit machines because the 32bit versions will usually never work on the 64bit machines. I'm dealing with one of these little headaches now...
|
|
|
|
|
hi
i have one asp.project and one reporting sever (using ssrs) i need to integrate the report manager to asp.net project...pls give me some hint
|
|
|
|
|
|
Thanks lot....
i need to manage the report server in my asp.net project.do not call the rdl only.The whole report manager i need to handle in my project .is it possible?
|
|
|
|
|
Hello,
Im writing an application based on .NET 4 framework but in my application i am using an assembley based on .NET 2 framework.
What do i need to to combine those two?
Thanks
|
|
|
|
|
You don't need to do anything. You can reference the 2.0 assembly in your project like any other assembly
No comment
|
|
|
|
|
If a .net dll is built in lower version(2.0),it can be easily used in higher version(4.0) by just referencing it.
I want to explain one more thing related to that-
But the the same dll is built in higher version(4.0), it can not used in Lower version(2.0) because .net does not support forward to backword compatibility that means upper to lower.
|
|
|
|
|
what exactly a .net can u give brief idea about it
|
|
|
|
|
This is not the place. There are lots of resources on the internet which can help you, starting here[^]. You could also take a look at .Net Book Zero[^] by Charles Petzold.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Can you list all disadvantages of Code-First model in Entity Framework 4.1
Thanks
Thien
|
|
|
|
|
No I can't. I'm sure I could come up with quite a few, but whether or not I'd get them all is a different matter.
|
|
|
|
|
Having to actually think about and plan your design upfront is certainly a disadvantage for some.
No comment
|
|
|
|
|
Can you spell Google?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi developers.
For caching data provided by a special server file I created an EntityModel which I store in a SQL CE database. Each time the user triggers an update of the database it should get resetted completely as it never had any data stored. That includes:
- Delete all entries of all tables
- Reset all indices
- Reset all identitys (auto increments)
But I don't have any idea how to wipe all the data and reset the tables. I want to keep the current database connection running and don't create an additional file.
Does any one have an idea how to reset the whole database to a fresh state?
Greetings
Daniel
|
|
|
|
|
To clear the tables you would use either of these
DELETE FROM [table name]
TUNCATE TABLE [table name]
To reset the identity columns
DBCC CHECKIDENT([table name], RESEED, 0)
Note I'm not certain these are available with SQL CE, but it should give you a start
No comment
|
|
|
|
|
I solved it using those statements, thanks. I was just wondering if there was any more common method for that:
private bool DeleteOldData()
{
using (var transaction = BeginTransaction(_database))
{
try
{
string[] tables = { "NToMMappingTable", "Table1", "Table2", "Table3", "Table4" };
bool[] alter = { false, true, true, true, true };
for (int i = 0; i < tables.Length; i++)
{
string table = tables[i];
_database.ExecuteStoreCommand(string.Format("DELETE FROM [{0}]", table));
if (alter[i])
_database.ExecuteStoreCommand(
string.Format("ALTER TABLE [{0}] ALTER COLUMN Id IDENTITY (1,1)", table));
}
transaction.Commit();
_database.AcceptAllChanges();
success = true;
}
catch (Exception e)
{
transaction.Rollback();
throw;
}
}
}
public static DbTransaction BeginTransaction(ObjectContext context)
{
if (context.Connection.State != ConnectionState.Open)
{
context.Connection.Open();
}
return context.Connection.BeginTransaction();
}
SQL CE does not support truncate or dbcc, but delete and alter table will work.
Thanks.
|
|
|
|
|
I was wondering which are the recommended ORM's for use with Microsoft Access? Specifically Access 97 and 2010!
We currently have a shed-load of Access 97 databases and an impending Office 2010 rollout, and as budget/time won't allow for conversion to SQL Server, we thought a first step would be replacing the front-ends with .NET WinForm apps. That way we could then migrate the backend to 2010 (or SQL) at a later date.
As far as I can tell EF and Linq2SQL don't work with Access (unless someone knows otherwise!). DataSets do (or at least should, can't get 2010 to work so far), but I was wondering if there was a more featured ORM that supported Access? Ideally with a visual designer.
My initial investigations have turned up Habanero, NHibernate and nHydrate.
|
|
|
|