I am attempting to write something in CBuilder 6 (target XP Professional). Thing about this service's job would be to monitor increase a table on the database. We use direct ODBC for connecting towards the database, the main problem is going on with ADO too, so we'll use that for simplicities sake.

You can observe my code below. This really is known as from the function that is performed within the ServiceStart event.

My problem is, I am unable to obtain a connection. Our MSSQL DB uses domain authentication, and so i have attempted running the service using my domain account. I have also attempted clearly determining my domainusername and password but that does not work either (within the qualities for that service, login tab).

Can anybody whatsoever assist me to with this particular? Anything whatsoever is appreciated.

Another question I've is when would one debug something? I've remote debugger installed. Will I spawn the procedure using something similar to rundll32.exe or something like that? Again, any help appreciate.

Many thank ahead of time

Stu.

Code Snippet:

TADOConnection* DB = new TADOConnection(this);
  try
  {
    DB->ConnectionString = "Provider=MSDASQL.1;Password=password;Persist Security Info=True;User ID=usernamej;Data Source=datasource";
    DB->Connected = true;

    returnValue = DB->Connected;
    ShowMessage("Connected");
  }
  catch (Exception &exception)
  {
    ShowMessage("Not COnnected");
  }

Notes: The connectionstring rentals are indicative only and it has had the username, password and database transformed. By using this string inside a stand alone application produces a consistently effective connection and data could be fetched utilizing a query.


In Reaction to JP:

Hi JP.

Interesting comment. I am really not receiving the best tossed here (that is strange). I modified the code (see below) to incorporate a couple of more msgboxes and the only person I see is the first - trying connection.

ShowMessage("Attempting Login"); 
TADOConnection* DB = new TADOConnection(NULL); 
try { 
  ShowMessage("1"); 
  DB->ConnectionString = "<as before>"; 
  ShowMessage("2"); 
  DB->Connected = true; 
  ShowMessage("Connected"); 
} catch (Exception &exception) { 
  ShowMessage(exception.Message); 
  ShowMessage("Not COnnected"); 

}

Any ideas? I cant understand why the bond component is not even being produced (note I attempted altering the dog owner out of this to NULL too simply to see an amount happen).

Thanks!

Stu.

If you work with domain authentication, you should not possess a user title or password inside your connection string:

Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;

Or perhaps an appropriate variant from http://www.connectionstrings.com/sql-server-2005

Your pc will have to be part of the domain and also the database server will have to trust that domain. The service will have to be running within account underneath the domain which the pc is really a member.

What you're encountering may be the Home windows Service permissions problems.

  • Basically, services reside in a decreased permissions atmosphere.

  • It is best to log towards the Event Log.

  • Produced home windows are only displayed should you run it as being Local Service with Interactive Desktop enabled.