|
Hi
You can not call window service in any project because it is not like class library.
I am not getting what are you doing with window service. Please explain what is is currently doing and what are you planning to do?
himanshu
modified on Monday, June 29, 2009 8:28 AM
|
|
|
|
|
what am trying to do is
i want to insert records into a sqlTable for that i created a method with 4 arguments in windows services class.
inside that method i wrote code to insert those 4 arguments.
i installed this windows service.
from another project i want to call this method
To insert records from a form i called that service like this
WindowsService1.Service1 winService = new WindowsService1.Service1();<br />
winService.insertValues(txtcustId.Text, txtcustName.Text, txtcustPhone.Text, txtcustAddress.Text);
here insertValues is my method inside windows service, where i wrote insert statement.
is this correct way?
when i tried to build it is giving below error
<br />
Error 2 The type 'System.ServiceProcess.ServiceBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. C:\Inetpub\wwwroot\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs 451 13 WindowsFormsApplication1<br />
modified on Monday, June 29, 2009 8:37 AM
|
|
|
|
|
Hi,
Stop your service from services.msc and check weather you are still able to insert records into your sql table. Just check it and you will find your answer
himanshu
|
|
|
|
|
am giving my code sample
<br />
protected override void OnStart(string[] args)<br />
{<br />
insertValues(3, "Naresh Kumar", "3658213641", "Begumpet Hyderabad");<br />
}<br />
<br />
public void insertValues(int custId, string custName, string custPhone, string custAdd)<br />
{<br />
string insertCommand = "Insert into CUSTOMER values ( " + custId + ",'" + custName + "','" + custPhone + "','" + custAdd + "')";<br />
con.Open();<br />
cmd = new SqlCommand(insertCommand, con);<br />
cmd.ExecuteNonQuery();<br />
con.Close();<br />
}<br />
when am trying run this service from computer Mangement
is it displaying below alert
"The service on local machine started and stopped. some services stopped automatically if they have no work to do for example the performance logs and alerts service."
please help me out.
|
|
|
|
|
Narendra Reddy Vajrala wrote: "The service on local machine started and stopped. some services stopped automatically if they have no work to do for example the performance logs and alerts service.
This error means there is some error in the code of your window service. You have not done any exception handling.Write Try/Catch block to catch the exception and log that error in event viewer or log file.
himanshu
|
|
|
|
|
same error
no change
even i used try catch block.
|
|
|
|
|
Hi
Have you log your error in log file or somewhere else...
Read error from there and post it.
Also, Do not use window service for this task.
himanshu
|
|
|
|
|
Hi
if you want to achieve this type of functionality than i suggest you to consider webservice.Using window service you will not achieve this. Moreover,there is no point to keep busy your server by making window service.
himanshu
|
|
|
|
|
ya
actually but i have to do in windows services only.
|
|
|
|
|
Narendra Reddy Vajrala wrote: actually but i have to do in windows services only
why? Says who?
|
|
|
|
|
i cant break my PL orders
|
|
|
|
|
who make him PL .
Use web service..
himanshu
|
|
|
|
|
What is a "PL" and what specifically are their/it's "orders"?
|
|
|
|
|
Project Lead, sounds like a cretin who's just been promoted into management by virtue of warming the seat for X years and is out to show his minions who's boss.
Cheers,
Vikram. Recent activities:
TV series: Friends, season 9
Books: Freakonomics, by Steven Levitt and Stephen J Dubner. Carpe Diem.
|
|
|
|
|
Ah ok, I guess we have PM's (Project Managers) but they don't get involved with how the thing is written, or Technical Lead's which do. Hence my confusion.
Anyway, he might have a valid reason for wanting to send all database communication through a windows service (ie, single point of caching) but he's obviously not been specific enough on how to communicate with this service for his more junior team members.
|
|
|
|
|
You are confusing web services and Windows services. I suggest you buy a book.
Cheers,
Vikram. Recent activities:
TV series: Friends, season 9
Books: Freakonomics, by Steven Levitt and Stephen J Dubner. Carpe Diem.
|
|
|
|
|
my code is like this in windows services class
<br />
protected override void OnStart(string[] args)<br />
{<br />
insertValues(3, "Naresh Kumar", "3658213641", "Begumpet, Hyderabad");<br />
}<br />
<br />
public void insertValues(int custId, string custName, string custPhone, string custAdd)<br />
{<br />
string insertCommand = "Insert into CUSTOMER values ( " + custId + ",'" + custName + "','" + custPhone + "','" + custAdd + "')";<br />
con.Open();<br />
cmd = new SqlCommand(insertCommand, con);<br />
cmd.ExecuteNonQuery();<br />
con.Close();<br />
}<br />
when am trying run this service from computer Mangement
is it displaying below alert
"The service on local machine started and stopped. some services stopped automatically if they have no work to do for example the performance logs and alerts service."
please help me out
|
|
|
|
|
The reason it stopped automatically is because there is no further work for the service to do once the line insertValue(...) has run.
In general, windows services' OnStart method starts a thread/timer which continues to process until interupted by a Pause or Stop command.
Whatever a "PL" is, he is an idiot, or you have misunderstood his request.
|
|
|
|
|
Hi,
I have a template in location " c:\excel_temp\template1.xls". This template is a user defined template.
I have to use this template in a browsed location. ( if user selects "d:\temp\" folder, then I have to import the template in " c:\excel_temp" to "d:\temp" folder).
I am trying this with C#. i have done somepart of it
string tempPath = @"D:\Documents and Settings\eob\Desktop\Testing";
//System.IO.Directory.CreateDirectory(@tempPath + launchName);
//check path exists
if (!System.IO.Directory.Exists(@tempPath + launchName))
{
System.IO.Directory.CreateDirectory(@tempPath + launchName);
}
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(@tempPath + launchName);
int directoryCount = dir.GetFiles().Length;
if (directoryCount != 0)
{
FileInfo[] fileNames = dir.GetFiles(@tempPath + launchName);
}
Excel.Application excelFile = new Excel.ApplicationClass();
Now with the excelFile created above, I have to access the template and create an excel file same as the template in the above folder.
I am stuck at this point, pls guide me
Thanks
Ramm
|
|
|
|
|
Krishna Aditya wrote: I have a template in location " c:\excel_temp\template1.xls". This template is a user defined template.
I have to use this template in a browsed location. ( if user selects "d:\temp\" folder, then I have to import the template in " c:\excel_temp" to "d:\temp" folder).
for this you can use:
string source = "c:\excel_temp\template1.xls";
string Destination = "d:\temp\Temp.xls";
if (File.Exists(Destination))
{
File.Copy(source, Destination, true);
}
//refer : Word automation (Part 1)[^]
modified on Monday, June 29, 2009 7:37 AM
|
|
|
|
|
Hello Experts
I want to make my columnheader Readonly of my datagrid...
|
|
|
|
|
what do you want with columnheader readonly ?
do you mean "not clickable and not sortable" ?
|
|
|
|
|
Yes i want that it should not be clicked,because when i click header, my control goes in cell click event and executes the code in it and error arises.
|
|
|
|
|
private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
if(e.RowIndex < 0)
return;
}
|
|
|
|
|