Click here to Skip to main content
16,006,535 members
Home / Discussions / C#
   

C#

 
QuestionHow to retrieve selected value from list view? Pin
yuenli17-Mar-08 11:59
yuenli17-Mar-08 11:59 
AnswerRe: How to retrieve selected value from list view? Pin
mmikey717-Mar-08 13:51
mmikey717-Mar-08 13:51 
AnswerRe: How to retrieve selected value from list view? Pin
Xmen Real 17-Mar-08 15:28
professional Xmen Real 17-Mar-08 15:28 
GeneralArithmetic Problem Pin
CNewbie17-Mar-08 11:34
CNewbie17-Mar-08 11:34 
GeneralRe: Arithmetic Problem Pin
Luc Pattyn17-Mar-08 11:50
sitebuilderLuc Pattyn17-Mar-08 11:50 
GeneralRe: Arithmetic Problem Pin
mmikey717-Mar-08 13:26
mmikey717-Mar-08 13:26 
QuestionUDT - InvalidOperiationException: invalid Value for OracleObjectMappingAttribute Pin
faehne17-Mar-08 11:04
faehne17-Mar-08 11:04 
Questionwindows service using C# Pin
Knowledgestudent17-Mar-08 10:55
Knowledgestudent17-Mar-08 10:55 
hi there,
I am trying to make my service to insert to a database when it starts as follows :

protected override void OnStart(string[] args)<br />
        {<br />
           base.OnStart(args);<br />
            string query;<br />
            id += 1;<br />
            <br />
          SqlCommand comm;<br />
          conn = new SqlConnection("my connection string");<br />
          query = "insert into myTable values('" + id + "',lamya'" +"')";<br />
            comm = new SqlCommand(query, conn);<br />
            <br />
                try<br />
                {<br />
                    conn.Open();<br />
<br />
                    while (id >= 120)<br />
                    {<br />
                        comm.ExecuteScalar();<br />
         query = "insert into myTable values('" + id + "',lamya'" + "')";<br />
                        comm = new SqlCommand(query, conn);<br />
                        id++; <br />
                                                                        <br />
                    }<br />
                    conn.close();<br />
<br />
                }<br />
                catch (Exception ex)<br />
                {<br />
                    //throw ex;<br />
                }<br />
<br />
                          <br />
        }


after adding an installer and installing the service using the Installutil.exe

when I start the service from the services manager this msg shows up:

The ServiceOnTest service on your Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the performance Logs and the Alters service.

where ServiceOnTest is the service name ,

just to know if it matters: the startup type is automatically and it run for the local System


what should I do to make it work, I need it to insert to the database and more but first I need to know what wrong I did?

Urgent help is needed , please
Thanks

There is always something to learn

GeneralRe: windows service using C# Pin
Mark J. Miller17-Mar-08 11:07
Mark J. Miller17-Mar-08 11:07 
GeneralRe: windows service using C# Pin
PIEBALDconsult17-Mar-08 12:15
mvePIEBALDconsult17-Mar-08 12:15 
QuestionRe: windows service using C# Pin
Knowledgestudent18-Mar-08 0:03
Knowledgestudent18-Mar-08 0:03 
GeneralRe: windows service using C# Pin
Stu Richardson18-Mar-08 2:50
Stu Richardson18-Mar-08 2:50 
QuestionRe: windows service using C# Pin
Knowledgestudent18-Mar-08 23:48
Knowledgestudent18-Mar-08 23:48 
GeneralRe: windows service using C# Pin
Stu Richardson19-Mar-08 0:19
Stu Richardson19-Mar-08 0:19 
QuestionRe: windows service using C# Pin
Knowledgestudent19-Mar-08 0:35
Knowledgestudent19-Mar-08 0:35 
GeneralRe: windows service using C# Pin
Stu Richardson19-Mar-08 1:09
Stu Richardson19-Mar-08 1:09 
GeneralRe: windows service using C# Pin
Knowledgestudent19-Mar-08 2:19
Knowledgestudent19-Mar-08 2:19 
GeneralRe: windows service using C# Pin
PIEBALDconsult18-Mar-08 6:14
mvePIEBALDconsult18-Mar-08 6:14 
NewsWhirlwind 1 -- Generics now posted on Channel 9 Pin
brucedkyle17-Mar-08 9:38
brucedkyle17-Mar-08 9:38 
GeneralRe: Whirlwind 1 -- Generics now posted on Channel 9 Pin
pmarfleet17-Mar-08 10:42
pmarfleet17-Mar-08 10:42 
GeneralRe: Whirlwind 1 -- Generics now posted on Channel 9 Pin
Not Active17-Mar-08 11:25
mentorNot Active17-Mar-08 11:25 
QuestionDebug into unmanage code?? Pin
Small Rat17-Mar-08 9:13
Small Rat17-Mar-08 9:13 
GeneralRe: Debug into unmanage code?? Pin
led mike17-Mar-08 9:16
led mike17-Mar-08 9:16 
GeneralRe: Debug into unmanage code?? Pin
Small Rat17-Mar-08 9:20
Small Rat17-Mar-08 9:20 
QuestionSaving Bitmap File To MS Access 2003 Problem Pin
cyberE-gor17-Mar-08 8:31
cyberE-gor17-Mar-08 8:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.