|
You can declare the variable (say myVar ) as a static member of a class (say myClass ) and then access it, wherever you need, simply using myClass.myVar .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
hello people,
I have an sql connection like the following. it works perfectly fine. I am using sql server'05.
SqlConnection conn = new SqlConnection("Data Source=" + Environment.MachineName + "\\WINCC;Integrated Security=SSPI;Initial Catalog=Logger; Packet Size = 32766;");
However, i want to have a connection so that my application runs on any machine, that does not have the sql server.
thanks
Keshav Kamat
India
|
|
|
|
|
Keshav V. Kamat wrote: i want to have a connection so that my application runs on any machine
Activate TCP/IP and the "Server Browser Service" in the SQLServer's configuration dialog.
Locally, the SQLServer uses Named Pipes fpor comminucation with clients.
To talk to remote clients, it needs CP/IP.
To find the instance "WINCC" by name, the clients need the browsing service.
____________________________________
There is no proof for this sentence.
|
|
|
|
|
Thanks.
But still, I want the connection to work when there is no SQL installed on a machine.
instance "WINCC" is fine. i could let an open file dialog or a simple text box do the job.
But I feel creating a database without any data source would be impossible.
thanks anyways.
Keshav Kamat
India
|
|
|
|
|
SQLServer can run on any remote machine. The client application finds the server by servername\instancename in the connection string. Activate TCP/IP and Browser Service on the remote server and your clients will run fine.
____________________________________
There is no proof for this sentence.
|
|
|
|
|
Hi,all
I am creating a editor and main from is made as an MDI parent and i want to implement a Find Functionality..
if i opened the Find form and Minimize the main from the find also should be minimized ..
i want something like pls refer..
open notepad Type somethingclick Find and minimize the notepad....
the find form also will be minimized like...
the same thing
With Regards
prasad
|
|
|
|
|
Hi, i try to help you.
If Form2 should do the same like Form1, you should try to create the Form2 in Form1.
So you have a reference to the Form2. You create form2 for example at the constructor of form1.
MyForm1::MyForm1(void)
{
OtherForm = new MyForm2; ( OtherForm should be a class member, to have all the time an access)
}
then you derive the ShowDialog() Method. there in you call naturally the base-method and then the ShowDialog of the Form2 "OtherForm.ShowDialog"
In this way you proceed with all methods you need.
If ShowDialog is protected/private for Form2, you need to derive also ShowDialog from Form2 but
as public.
I hope i could help you a little bit.
Good luck
|
|
|
|
|
hi,friend
i will clear it u
I am creating a editor and main from is made as an MDI parent and i want to implement a Find Functionality..
if i opened the Find form and Minimize the main from the find also should be minimized ..
i want something like pls refer..
open notepad Type somethingclick Find and minimize the notepad....
the same thing
With Regatds
prasad
|
|
|
|
|
1. Use Show(), not ShowDialog()
2. Use event SizeChanged in Form1.
private void Form1_SizeChanged(object sender, EventArgs e)
{
this.form2.WindowState = this.WindowState;
}
|
|
|
|
|
hi,friend
i will clear it u
I am creating a editor and main from is made as an MDI parent and i want to implement a Find Functionality..
if i opened the Find form and Minimize the main from the find also should be minimized ..
i want something like pls refer..
open notepad Type somethingclick Find and minimize the notepad....
the same thing
With Regatds
prasad
|
|
|
|
|
yepp,
i came to the same solution.
But there is still the problem, that the "FindWindow" disappears behind the MainForm, if the
MainForm gets the focus.
But i never made things like this in C# before
|
|
|
|
|
Hi everyone,
Can anyone please tell me how do you get only the file name out of openFileDialog1.FileName, cuz I keep getting the path along with the file name.
Many thanks
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
<br />
string fileName = Path.GetFileName(openFileDialog1.FileName);<br />
|
|
|
|
|
Path what's this??
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hello,
Look at the System.IO namespace.
There you will find the path class, with a lot of fancy methods.
All the best,
Martin
|
|
|
|
|
Martin# wrote: ... a lot of fancy methods.
Thank you Martin, you're the fancy one
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
i hope this helps. this open file dialog is for xml files only. use the file extensions accordingly.
OpenFileDialog ofn = new OpenFileDialog();
ofn.Filter = "XML Files (*.xml)|*.xml";
ofn.Title = "Type File";
if (ofn.ShowDialog() == DialogResult.Ok)
{
}
then u can get the file name as
ofn.FileName
Keshav Kamat
India
|
|
|
|
|
Keshav V. Kamat wrote: i hope this helps
Sorry, but not at all I'm well familiar with the OpenFileDialog, my question was how to get only the file name and FileName property is giving me the full path.. thanks anyways buddy.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
hi all,
i am working in windows form, i couldn't reach to the destination file when in use(""..\\..\file name");
which method should i use to reach to a perticular dirctory of my machine,
i know in web i used to use server.mappath...but here i don't know,
bye byes
prashanth
|
|
|
|
|
if u want to know the application path of ur program then u can use
Application.StartupPath;
rahul
|
|
|
|
|
Hi
You can get using Application instead of Server. Try this
Application.StartupPath.ToString(); -> this will give the current application path.
There are some properties for the class Application like:
- ExecutablePath
- LocalUserAppDataPath
Hope this helps you.
Harini
|
|
|
|
|
Harini Krishnaswamy wrote: Application.StartupPath.ToString();
Application.StartupPath is already a string . Why do you put .ToString() on the end of it?
|
|
|
|
|
Hi Colin,
You are right. No need to give ToString(). Application.StartupPath is enough.
Harini
|
|
|
|
|
Hi
I am trying to develope an Utility to handle reporting of errors and exceptions in my application. Whenever an exception occurs I want the exception details to be written to a XML file.
I am using the following code, but it does not append to the file, it overwrites the previous data. How can I have the new exceptions append to the file so that I have a full history of all the exceptions without having to create a new file each time?
private static void LogException_XML(DateTime date, string fullpath, string localPath, Exception e)<br />
{<br />
try<br />
{<br />
XmlWriterSettings settings = new XmlWriterSettings();<br />
settings.Indent = true;<br />
settings.IndentChars = (" ");<br />
using (XmlWriter writer = XmlWriter.Create(fullpath, settings))<br />
{<br />
writer.WriteStartElement("Exception");<br />
writer.WriteElementString("Date", date.ToShortDateString());<br />
writer.WriteElementString("Time", date.ToShortTimeString());<br />
writer.WriteElementString("Message", e.Message);<br />
writer.WriteElementString("Source", e.Source);<br />
writer.WriteElementString("Stacktrace", e.StackTrace);<br />
writer.WriteElementString("TargetSite", e.TargetSite.ToString());<br />
writer.WriteElementString("TargetSite", e.TargetSite.ToString());<br />
writer.WriteEndElement();<br />
writer.Flush();<br />
}<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
throw ex;<br />
}<br />
}
Thanks.
Kobus
|
|
|
|
|
You could use an overload of the XmlWriter.Create method that takes a Stream instance instead of the filepath and explicitely create a FileStream that appends to the file, but this will create invalid XML since an XML document must have a single root element. I'm not sure how hard it is to position the XmlWriter in a way that you will overwrite the closing root element tag, so I recommend the XmlDocument class.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|