|
Maybe I misunderstood, but are you assuming that writing HTML code and setting the content-type to 'application/pdf' will give you a valid PDF file? That's totally wrong!!
You should use a PDF library for that. I recommend PDF Sharp, which is free.
Also, use the StingBuilder class if you want to append characters to an existing string. It's far more efficient.
|
|
|
|
|
Hi,
I have 1 form with 10 userforms inside, that i use as pages.OK
take a look on this!!!
(coding is the same kind in all userforms, but not the same,ok?!)
in form:
private void Form_Main_Load(object sender, EventArgs e)
{UserControl_DriverPage_Child.Event_DriverPageInfo += new UserControl_DriverPage.Delegate_DriverPageInfo(Page_Info);}
protected void Page_Info(string msg)
{ToolStripStatusLabel_MainInfo.Text = msg;}
in userform:
public delegate void Delegate_DriverPageInfo(string msg);
public event Delegate_DriverPageInfo Event_DriverPageInfo;
now in the same userform(or others) i place this inside routines
that handle events such like button_click,textbox_textchanged, etc
Event_ConstructorPageInfo("OK: constructor added");
this stuff is so wierd that works in some userforms routines others
don´t. I get this exception:
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
...bla bla bla
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Looks OK to me.
Have you stepped through it with the debugger?
Usually with events you should check to see if there are handlers attached.
|
|
|
|
|
As PiebaldConsult said - check that there are subscribers to the events before raising them.
The standard way is something like:
public delegate void Delegate_DriverPageInfo(string msg);
public event Delegate_DriverPageInfo Event_DriverPageInfo;
public void YourMethod()
{
OnEvent_DriverPageInfo("Message");
}
protected virtual void OnEvent_DriverPageInfo(string message)
{
if (Event_DriverPageInfo != null)
Event_DriverPageInfo(message);
}
It's actually more normal to have your own class that derives from event args and pass the message that way - but it's not neccesary, just the norm.
public class DriverPageInfoEventArgs : EventArgs
{
public DriverPageInfoEventArgs(string message)
{
m_Message = message;
}
private string m_Message;
public string Message
{
get{ return m_Message; }
}
}
...
public delegate void Delegate_DriverPageInfo(object sender, DriverPageInfoEventArgs e);
public event Delegate_DriverPageInfo Event_DriverPageInfo;
public void YourMethod()
{
DriverPageInfoEventArgs e = new DriverPageInfoEventArgs("Message");
OnEvent_DriverPageInfo(e);
}
protected virtual void OnEvent_DriverPageInfo(DriverPageInfoEventArgs e)
{
if (Event_DriverPageInfo != null)
Event_DriverPageInfo(this, e);
}
Whichever way, the important thing is the null check in the OnEvent... method.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
thanks i am going to follow that, new stuff i see.
wierd to work/notwork in routines that are alike
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Hi, there
I am using 2005 C# express,
OracleDataAdapter oraAdt = new OracleDataAdapter(s, oraconn);
oraAdt.Fill(ds);
# s is my SQL statement
My screen freezes while waiting for the results back. How can I still work on the screen while waiting for the results.
Thanks,
|
|
|
|
|
You could try doing the supplied code on a separate thread.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Like Paul said, use a separate thread. Probably you should use a BackgroundWorker , there are plenty of examples about it here on CP and the rest of the internet.
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
that thread stuff is good idea like said, but you may want to check your sql code, is there a forever loop?
i have some store_procedures that "take a while", but they do create tables, read othertable,insert into othertable,drop all, selectall.
So in my opinion check it
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
I use the following Code to fill a DataGrid:
private bool DataGridFuellen(string strDatenbankPfad, string strTabellenName)
{
try
{
OleDbConnection Datenbankverbindung = DatenbankVerbindungOeffnen(strDatenbankPfad);
OleDbCommand Befehl = new OleDbCommand();
OleDbDataAdapter DatenAdapter = new OleDbDataAdapter(Befehl);
DataTable Tabelle = new DataTable();
Befehl.CommandText = "SELECT * FROM " + treeView_Tabellen.SelectedNode.Text;
Befehl.Connection = Datenbankverbindung;
Tabelle.Locale = System.Globalization.CultureInfo.InvariantCulture;
DatenAdapter.Fill(Tabelle);
dataGridView_TabellenInhalt.DataSource = Tabelle;
Datenbankverbindung.Close();
return true;
}
catch (Exception E)
{
MessageBox.Show("Beim Füllen des DataGrid ist ein Fehler aufgetreten: " + E.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
If the Scourcetable is very big, the process takes a long time and the user doesn't see, that the computer is still working.
I like to add a progressbar to visualize the working process, but my problem is, that i don't know how much data has been loaded out of the table.
Is there any way to get the actual point in the table.
I tried to add several eventhandlers, for example Dataadapter.RowUpdated, but it doesn't work yet.
|
|
|
|
|
Your can't use a progress bar in the sense that you see progress going from 0% to 100%. The SQL command doesn't report any progress so there's nothing to show. You can only use the Marquee style of a ProgressBar that shows moving boxes. This is just to show that something is happening.
Also, in order to get the Marquee to update and move the boxes, you'll have to move the code that does the database fetch to a background thread. This will free up the UI thread so your progress bar can get and process the WM_PAINT messages it needs to see. Look into the BackgroundWorker component for more information.
|
|
|
|
|
Sometimes uses do not have access to internet so I need to save data locally. I can not afford to put a SQL DB onto every machine. I was thinking of using an XML file but that is not a good option as I have to worry about serialzation etc. Is there an alternative to SQL? Can I use SQL Compact Edition?
|
|
|
|
|
This is one of the purposes that SQL CE is designed for so it should be a good choice (no installation, only single user etc...).
The need to optimize rises from a bad design
|
|
|
|
|
CodingYoshi wrote: Can I use SQL Compact Edition?
Quote Selected Text
Yes, that's the idea of it. It can be used for local, single user installs. As far as serialization is concerned, you'll have to have some type of mechanism that keeps the main database in synch with the local database.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
CodingYoshi wrote: Can I use SQL Compact Edition?
You can. If they need to merge changes into a master system, you could always use the Sync framework.
|
|
|
|
|
|
Hi All,
I have a little application maded with Visual Studio 2005 and SqlServer that shows the status of plans/activities. Kind of dashboard.
Now i have to show this dashboard on a PDA.
My questions is what do i have need/use for this?
Can anyone give me some info or references about this subject?
Thanx.
|
|
|
|
|
It can be done no problem with Visual Studio 2005 (I'm using 2008 now and have removed 2005 so I can't give you the exact steps, but I did several PDA apps with 2005). For the database, you can either connect remotely or use MS SQL CE locally.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Hi Dave,
Thanx for your response.
Could you give me the steps with VS 2008 ?
Thanx.
|
|
|
|
|
Create project | Smart Device | Smart Device Project
Name it and click OK
Select Target platform and .NET Compact Framework Version then Device Application.
There are differences between .NET [standard] and .NET Compact but *most* things will pretty much work by copying and pasting your code from your existing app.
You can connect to any database you like, but because of potential connection issues, any data that needs to be stored locally should be done in MS SQL CE and synchronized later (either over the internet/LAN or active sync). Just goto the normal Data menu and do/add what you need.
You can debug either in the built in Emulator or to your device if it's connected to the dev machine. This is the painful bit as it can take a while!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thanx a lot. That was very helpfull
|
|
|
|
|
What is the best way to avoid connection, or thread pool limitations for my application? And am I doing it correctly?
I'm designing my own chat. It's necessary because my design is very different from any available out there. Because of the new security features in IE I can't use a different server than my website server for processing chat requests. I'm forced to combine my web app with my chat server.
So, my plan was to use ajax to make a page request. The page would then use asp.net 2.0's asynchronous pages feature to start a new thread and release the Thread that processes page requests. Then my plan was to have the thread wait until a new message comes in if I have no messages to send to the client immediately.
My two main uncertainties are this:
1) How do I best wait for new messages? Should I use a wait and notify? Should I use a WaitHandle(never used it before). Will I run out of threads in the thread pool from using these methods because they block? Is there a way to wait and release the threads at the same time?
2) Is there a limit on the number of connections that can be made to a web server. I want every client on my website to be able to receive notifications of new chat messages immediately, without polling. So, am I doing it right or should I use some sort of callback method that doesn't keep a connection open. is that possible???
|
|
|
|
|
I am trying to start an instance of an Outlook mail message with a few files attached, and am having some difficulty. I have about googled my fingers off to no avail...
The code I have currently will work for only 1 attachment:
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("OUTLOOK.exe");
psi.Arguments = "/a \"c:\\myfile.txt\"" ;
System.Diagnostics.Process.Start(psi);
I have tried specifying multiple /a command line switches to get multiple files attached such as /a "file 1" /a "file 2" , and I have tried arguments /a "file 1" "file 2" as well. I have had no luck with either approach.
Does anyone know of a way to specify multiple attachments through a command line argument?
Thanks for your help.
|
|
|
|
|
After doing more research, it seems that the only way to accomplish this is through the user of Interop libraries. This link[^] may be of use to others who are trying to solve the same problem that I was.
|
|
|
|
|
I need to serialize some class using XmlSerializer and write them to file. How can I do so if I want to use the same file and append more objects to it? For example, if I want to save Student records to xml file, first I will use the XmlSerializer to serialize the Student object. Then I can write it to a file called Students.Xml. If I want to write more students to the same file how can I append it to the existing file? The XmlSerializer adds extra elements which I do not need on every successive record. It adds tags like <student xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" datetimevalue="2008-09-24">
|
|
|
|