|
Hi all,
I have written all the data to the XML file. Now I read the XML data in to a XElement. I want to add a new controller to the second plant within the XML data, but it keeps adding it to the first plant. I know why ... I just don't know how I can add it to the second plant ... could anyone please help me out with this one?
<root>
<!--First Plant-->
<plant>
<!--First Building in Plant 1-->
<building>
<controller>
<reader/>
</controller>
<controller>
<reader/>
</controller>
</building>
<!--Second Building in Plant 1-->
<building>
<controller>
<reader/>
</controller>
<controller>
<reader/>
</controller>
</building>
</plant>
<!--Second Plant-->
<plant>
<!--First Building in Plant 2-->
<building>
<controller>
<reader/>
</controller>
<controller>
<reader/>
</controller>
</building>
</plant>
</root>
Many thanks in advance
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
What the heck is an XElement?
|
|
|
|
|
|
Hai friends,
I tried to open IE using the following code,
SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorerClass();
IWebBrowserApp wb = (IWebBrowserApp) ie;
wb.Visible = false;
object o = null;
wb.Navigate(url, ref o, ref o, ref o, ref o);
My questions is, using similar logic can I move IE to back and Forward.
Please suggest me any method to that.
|
|
|
|
|
Hey
i can suggest, you can have two stacks for Forward and Backward
using that stack the URLs and navigate programaticaly
thanks
|
|
|
|
|
Thanks for your reply jasome,
But I want to use "GoBack()" and "GoForward()" functions of "SHDocVw.InternetExplorer".
|
|
|
|
|
I want to connect to a DataBase and then add table to this database in runtime,
my code is:
private void button1_Click(object sender, EventArgs e)
{
string strsql = "create table tbl_" + textBox1.Text + "(tbl_id bigint identity(1,1) primary key)";
SqlConnection connection = new SqlConnection(@"Data Source=YOUR-6BBD24890A\Q;Initial Catalog=sepehr;Integrated Security=True;User Instance=True");
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandText = strsql;
connection.Open();
command.ExecuteNonQuery();
connection.Close();
toolStripStatusLabel1.Text = "Table Added To DataBase";
}
what's this error???
A user instance was requested in the connection string but the server specified does not support this option.
Changed database context to 'master'.
Changed language setting to us_english.
please help me as soon as possible
|
|
|
|
|
|
Hi.
I've created a windows service and installed it. ( I saw it in Computer Management -> Services )
Then I've started it with following code :
static void StartService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
There are two methods in my windows service :
protected override void OnStart()
{
FileStream fs = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\mds.txt", FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
m_streamWriter.WriteLine(" mcWindowsService: Service Started \n");
m_streamWriter.Flush();
}
protected override void OnStop()
{
FileStream fs = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\mds.txt", FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
m_streamWriter.WriteLine(" mcWindowsService: Service Stopped \n");
m_streamWriter.Flush();
}
But nothing is done !!!
I mean when I start it OnStart() doesn't execute.
What's wrong with it ?
Could you please guide me ?
Thanks.
|
|
|
|
|
Is this service installed? Are you able to start it from service control manager? Are you getting any error?
|
|
|
|
|
N a v a n e e t h wrote: Is this service installed?
Yeah, It was installed currently, I can see it in Computer Management -> Services but I can't start it from there. I don't know why and I don't getting any errors !
BTW : I've set StartType property to Automatic .
modified on Thursday, September 3, 2009 7:30 AM
|
|
|
|
|
Try to wrap the file writing code in try/catch and write the exception in to event log. Also try with a hardcoded path something like C:\mcb.txt . I guess problem will be with the line Environment.GetFolderPath(Environment.SpecialFolder.Desktop) . You may need to turn Allow service to interact with Desktop option. Right click on your service and choose Properties -> Logon Tab -> Allow service to interact with desktop .
Your file writing code can also be improved. Here is an improved version.
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "\mds.txt")
using(StreamWriter writer = File.CreateText(path))
{
writer.WriteLine("mcWindowsService: Service Started \n");
}
|
|
|
|
|
Great, It works.
Thanks a lot N a v a n e e t h
I've test with C drive.
N a v a n e e t h wrote: You may need to turn Allow service to interact with Desktop option. Right click on your service and choose Properties -> Logon Tab -> Allow service to interact with desktop.
Where is Logon Tab ?
I've found it. Can we do it programmatic ?
modified on Friday, September 4, 2009 6:56 AM
|
|
|
|
|
Mohammad Dayyan wrote: I've found it. Can we do it programmatic ?
Not sure.
|
|
|
|
|
|
How do you know OnStart() doesn't execute? Is it because nothing is written to the file? I think you need to close your StreamWriter too, not only flush it.
|
|
|
|
|
Calla wrote: How do you know OnStart() doesn't execute?
If it executes , the file have to exist in Desktop , but the file doesn't create.
|
|
|
|
|
You need to find out whether the service is installed correctly or if you just have trouble creating and writing to the file.
Try writing something to the Application Log in the OnStart method of the service to verify the code is being run.
protected override void OnStart()
{
System.Diagnostics.EventLog.WriteEntry("In OnStart.", EventLogEntryType.Information);
}
|
|
|
|
|
Seems as the service is not installed correctly.Use InstallUtil,ServiceInstaller and ServiceProcessInstaller to figure it out.To debug the service you should open the project first and next use Attach to Process from tools menu to attach the service.
Life is a stage and we are all actors!
|
|
|
|
|
This is what I want to do:
- I have made a WSDL (interface) which can be implemented by different web-services. Lets call this provideData.wsdl
- I want to make a c# console application where I can dynamically add different services (different locations) which implements the same WSDL. Something like this:
static void Main(string[] args)<br />
{<br />
AddDataProvider("http://serviceA/a.asmx");<br />
AddDataProvider("https://serviceB/b.asmx");<br />
}
Normally when I consume a web-service in a C# project I just press "Add Service Reference...",
but how can I do this dynamically with code?
|
|
|
|
|
hello
how read memory variable file 0r files *.mem in c#.net?
|
|
|
|
|
If you just want to read the .mem file, it's easy :
byte[] array = File.ReadAllBytes(@"c:\test.mem");
|
|
|
|
|
|
|
Hello...
I m creating ASP Website in C#.
There is one drop down list and one text box
In drop down list, i have country's name.
Problem:
i just want is that textbox will display the selected item in drop down list.
Suppose if i select INDIA in Drop down list then textbox must display INDIA..
Please Help me out.
Thanks in Advance.
Lalit
|
|
|
|