|
You can use DBNull.Value for this.
mav
|
|
|
|
|
I want to serialize a class to an XML file. The class contains an array of objects. The objects are a class with 2 string members.
|
|
|
|
|
|
Hi,
I am making desktop application using C#
How can kill the process of excel file
Suppose i have opened Four Excel file
How I will detect which one to close the excel file
My application contains base files and all the tables are converted to Excel files
Excel files are invisible
what i noted that excel process is still running
I have to close the excel files after converting from database table to excel
How can i completely kill the process of excel file
regards
sanjeev
|
|
|
|
|
Isn't there a Close() or Quit() method for the Excel.Application object? I know there _is_ one for Word, so Excel should be similar...
IMHO you shouldn't kill the process, because if you need to do this it means that you haven't kept track of your references. Close all open Documents, then the COM server should shutdown, too. Or, as stated above, use Quit or something similar.
Regards,
mav
|
|
|
|
|
Ah, I have personally dealt with this before. The problem arises in the Office interop assemblies where if you do not practice the correct method of declaring variables, the instances will never go away. The first thing to remember is to never call something like:
Excel.Application oApp = new Excel.Application
...
Application.WorkBook....
What I mean by this is, you must explicitly declare each of the variables you intend to work with IE..
Excel.Application oApp = new Excel.Application
Excel.WorkBook oWB = Application.WorkBook
So any time you use a subclass within the Application model, make sure you declare a new variable for it instead of directly referencing it. The second most important thing is to lookup Microsofts NAR function and call NAR(...) on any object you create.
Excel.Application oApp = new Excel.Application
Excel.WorkBook oWB = Application.WorkBook
...
NAR(oWB);
NAR(oApp);
These two methods above will insure that all references to the Interop Assemblies are cleaned up, as the cause of lingering Excel applications are the lingering pointers to some aspect of its Application. If you need a better example I could provide you with one, I just do not have the code in front of me at the moment.
Good luck.
Here is the function provided by Microsoft:
private void NAR(object o)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(o);
}
catch {}
finally
{
o = null;
}
}
You might want to look at http://support.microsoft.com/default.aspx?scid=KB;EN-US;q317109& for a better idea if what I stated was not clear
|
|
|
|
|
In NDoc there are some additional XML tags defined that are not know to the Visual Studio 2003. As I use the autocompletion of VS2003 often even for the XML tags I am looking for a way to extend the list of the known tags and their attributes.
Is there a way to extend the list, maybe with an add-in or by editing an schema file or ...
Thanks
Roland
Wenn der Computer wirklich alles kann, dann kann er mich mal kreuzweise.
(Manfred Schmidt)
Follow your Euro notes in their tracks
|
|
|
|
|
In richtextbox, how to find & replace a string such as notepad of window ?
|
|
|
|
|
Find first occurrance:
int idx = richTextBox1.Text.IndexOf("SearchText");
Replace all occurrances:
richTextBox1.Text = richTextBox1.Text.Replace("text1", "TEXT2");
mav
|
|
|
|
|
Hi,
I am making desktop application using C#
When the application starts it should find out whether the Excel has been installed or not in that particular machine
When my application starts it should search for
Excel9.olb -- MS Excel 2000
Excel.exe-- MS Excel 2002
Excel.exe -- MX Excel 2003
I have to use this product in both operating system MS Windows XP and MS Windows 2000.
Any body can give me idea
|
|
|
|
|
can u not just look for HKEY_CLASSES_ROOT/.xls
if you find it excel is installed
regs
g00fy
|
|
|
|
|
Does your program only have to find out whether Excel is installed or do you want to do anything with Excel, once it's found?
I'd assume the latter, so you could simply try to instantiate an Excel.Application object and see if you get the object.
Place the call in a try/catch and you'll get the correct object or a COM exception telling you that Excel isn't installed (correctly).
Regards,
mav
|
|
|
|
|
Hi Mav,
Thanks for your reply.
How will i know which version has been installed on the particular computer.
I need basically three given below for my product.
If some one has installed Excel 97 or other version it should says the message pls installed only three version of Excell 2000,2002,2003.
When my application starts it should search for
Excel9.olb -- MS Excel 2000
Excel.exe-- MS Excel 2002
Excel.exe -- MX Excel 2003
I have to use this product in both operating system MS Windows XP and MS Windows 2000.
Accoding to your answer does Com intialization code will work for all of Excel version
regards
sanjeev
|
|
|
|
|
Can anybody tell me how to connect to a *.dbf file?
I tried via odbc and oledb.
ODBC
Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" + txtbox_filepath.Text + ";"
DRIVER={Microsoft dBase Driver (*.dbf)};DBQ=" + txtbox_filepath.Text + ";DriverId=533;MaxBufferSize=2048; PageTimeout=5"
OLEDB
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + txtbox_filepath.Text + ";Extended Properties=dBASE IV;User ID=; Password="
I've tried different variations and google and msdn tell me nothing new.
(txtbox_filepath.Text gives the path to the file)
I only try to open it and close it, but it still fails. The error message is something like invalid path, but after double and triple checking this, Removing the path (leaving the filename) and trying to add the directory with the odbc sources (via administrative tools), it still doesn't work
I'm at a loss here, hope somebody can help me...
tnx.
No hurries, no worries.
|
|
|
|
|
I create a registry key when i run at the first time my application (not during the installation).
I would set some parameter to the unistalling process that allow to delete that key or another key created by another software.
How?
Tnx.
|
|
|
|
|
Hi,
I am developing an wireless network monitoring tool. I am using CreateFile, DeviceIoControl and CloseHandle. So this is the plan to create the file to open the NDIS device any make the OIDs query. My problem the name of the file could not be mentioned. I took some help from rawether and some samples. But the Driver name "Ndisuio", when i create the file it returns the handle as -1. So i need the correct format of Specifying the first parameter(the driver filename) to the CreateFile. The code Actually is,
private const string NDIS_FILE_NAME = @"\\\\.\\Ndisuio";
DriverHandle = CreateFile(NDIS_FILE_NAME,
GENERIC_READ | GENERIC_WRITE, 0, 0,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
INVALID_HANDLE_VALUE);
My Question Actually is what this suppose to mean :" \\\\.\\Ndisuio". and how to make it relevent to my system. I am using Windows 2000 professional Built in NT technology.
|
|
|
|
|
I'm printing image with the help of PrintDocument in C#, When i use the print method , its shows the popup window showing "Printing 1 of........" , i don't want to show this window while printing,
Can anyone tell how can i make this.
|
|
|
|
|
Hi,
How can I communicate between two modems in C#?
Do we have some classes in the .NET framework or should we use API's or any other solution?
Please help me with some articles/links/suggestions.
Thanks in advance.
Subrahmanyam.
|
|
|
|
|
hi
this is my code which is working fine
but when i want to put user defined value from textbox to @name='here ib place of ram'
i get a sysntax error
XmlDocument doc = new XmlDocument();
doc.Load("c:/farm-config.xml");
xmlNode farm2=doc.SelectSingleNode("/root/farm-config/farm[./@name='ram']/connection/@address");
MessageBox.Show("sanjeev" + farm2.InnerText);
This is working fine
when i modify code
it gives some syntax error
xmlNode farm2=doc.SelectSingleNode("/root/farm-config/farm[./@name="+ textBox1.text + "]/connection/@address");
i tried this one also
xmlNode farm2=doc.SelectSingleNode("/root/farm-config/farm[./@name='"+ textBox1.text + "']/connection/@address");
can anyone correct me
this is my xml file sturcure
<?xml version="1.0" encoding="UTF-8"?>
<root>
<farm-config>
<farm name="good">
<connection address="localhost" user="god1" password="mad">
<lastjob>Copy-All</lastjob>
<lastconnection startdate="2005-05-10" starttime="12:43:23" enddate="2005-05-10" endtime="12:58:32" />
<state>1</state>
</connection>
</farm>
<farm name="sanjay">
<connection address="127.0.0.1" user="dog" password="cat">
<lastjob>Copy-All</lastjob>
<lastconnection startdate="2005-05-10" starttime="12:43:23" enddate="2005-05-10" endtime="12:58:32" />
<state>1</state>
</connection>
</farm>
<farm name="ram">
<connection address="localhost1" user="root" selectedConnection="1" password="daask">
<lastJob>Copy-All</lastJob>
<lastConnection startdate="2005-05-10" starttime="12:43:23" enddate="2005-05-10" endtime="12:58:32" />
<state>1</state>
</connection>
</farm>
</farm-config>
</root>
regards
sanjeev
|
|
|
|
|
Well Sanjeev, everything seems fine.... but there is one glitch which might be causing this problem. Since you are picking value from a textbox, perhaps there are trailing spaces in it. Why dont you first extract value from textbox, trim it and then try to find that node.
Like you can do this.
string strdata = Convert.tostring(textBox1.text).trim();
xmlNode farm2=doc.SelectSingleNode("/root/farm-config/farm[./@name='"+ strdata + "']/connection/@address");
Hope this resolves the problem!!!
Ali
http://aliwritings.blogspot.com/
|
|
|
|
|
I am developing a C# application with a form contains 3 comboboxes and all the 3 combo should get its data from a different fields in different tables in my database..
How can run this statement in C# with the faster performance?
Jassim Rahma
|
|
|
|
|
Run exch one on a seprate thread.
|
|
|
|
|
I have a solution that contains 4 projects. The main project is entitled Majo, which uses the Majo namespace IE:
namespace Majo
{
public class Majo : System.Windows.Forms.Form
{
...
In the Components project I have the following declaration:
namespace Majo
{
namespace Components
{
public class ImageComponent : PictureBox
{
....
The problem is I need to have access to the Majo class within the main Majo namespace, but if I just use Majo from the Components namespace, I get a
'Majo' denotes a 'namespace' where a 'class' was expected
How can I gain access to the Majo class from Components? Thanks.
|
|
|
|
|
Majo.Majo majo = new Majo();
IMO you'd do better to change the namespace name, it's potentially confusing.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I still get a
The type or namespace name 'Majo' does not exist in the class or namespace 'Majo' (are you missing an assembly reference?)
error if I attempt to use Majo.Majo. Is there someone I have to do to be able to reference the main class?
|
|
|
|