|
Member 11967800 wrote: it operated as a stupid. And exactly what are we to understand by that statement?
Member 11967800 wrote: but doesn't act well as a service. Or that?
Please edit your question and explain exactly what problems you see in the code when you try to run it.
|
|
|
|
|
Message Closed
-- modified 2-Nov-15 11:42am.
|
|
|
|
|
Sorry but that information does not give any clues. I can only suggest you add some more debugging logic to your service program to see what is happening.
|
|
|
|
|
Can I make debugging on the running service?
And I'm using VS2015 but service debugging is seen somewhat different with normal application.
Please teach me how to debug service program.
-- modified 2-Nov-15 11:37am.
|
|
|
|
|
|
Thank you for your kindly advice.
But my vaccine 365 security reject it as a virus. But www.virustotal.com doesn't report it as a virus. I also have no clue on it, maybe the vaccine detects the approach to the registry by debug mode built service.
Now I'm using Error log file and monitor its action.
Please check this function and give me your precious advice.
DALConnection::ExecutionResult
SQLiteRecordset::TryOpen(std::shared_ptr<dalconnection> pDALConn, const SQLCommand &command, String &sErrorMessage)
{
String sSQL = command.GetQueryString();
try
{
std::shared_ptr<sqliteconnection> pConn = std::static_pointer_cast <sqliteconnection>(pDALConn);
std::shared_ptr<sqlite3dbcpp> dbengin_ = pConn->GetConnection();
AnsiString sQuery;
if (!Unicode::WideToMultiByte(sSQL, sQuery))
{
ErrorManager::Instance()->ReportError(ErrorManager::Critical, 5108, "SQLiteRecordset::TryOpen", "Could not convert string into multi-byte.");
return DALConnection::DALUnknown;
}
record_cnt_ = cur_row_ = 0;
field_list_.clear();
value_list_.clear();
ErrorManager::Instance()->ReportError(ErrorManager::High, 3156, "SQLiteRecordset::TryOpen", sQuery);
/*
sQuery = "select * from my_settings";
If I set this value like this, SQL query will be succeed, but only using sQuery normally will be failed. Simple query such as "select * from my_dbversion" will be succeed but large data querying will be failed. I don't know the clue.
*/
SQLite3QueryCpp query_ = dbengin_->execQuery(sQuery);
int numFld = query_.numFields();
String data = "\n";
for (int i = 0; i < numFld; i++)
{
field_list_.push_back(query_.fieldName(i));
data += query_.fieldName(i);
data += "\t";
}
data += "\n";
while (!query_.eof())
{
std::vector<ansistring> sRow;
for (int i = 0; i < numFld; i++){
sRow.push_back(query_.fieldValue(i));
data += query_.fieldValue(i);
data += "\t";
}
data += "\n";
value_list_.push_back(sRow);
record_cnt_++;
query_.nextRow();
}
query_.finalize();
ErrorManager::Instance()->ReportError(ErrorManager::High, 3156, "SQLiteRecordset::TryOpen ...", data);
}
catch (...)
{
ErrorManager::Instance()->ReportError(ErrorManager::High, 4202, "SQLiteRecordset::TryOpen", "An unknown error occurred while executing " + sSQL);
return DALConnection::DALErrorInSQL;
}
return DALConnection::DALSuccess;
}
Error Log look like this
ERROR" 5928 "2015-11-02 18:17:33.876" "Severity: 1 (Critical), Code: HM3156, Source: SQLiteConnection::Connect Starting..., Description: e:\develop\MiniMail\Test\Database\MailServer.db3"
"ERROR" 5928 "2015-11-02 18:17:33.877" "Severity: 2 (High), Code: HM3156, Source: SQLiteRecordset::TryOpen, Description: select * from hm_dbversion"
"ERROR" 5928 "2015-11-02 18:17:33.879" "Severity: 2 (High), Code: HM3156, Source: SQLiteRecordset::TryOpen ..., Description:
value
5601
"
"ERROR" 5928 "2015-11-02 18:17:33.879" "Severity: 2 (High), Code: HM3156, Source: SQLiteRecordset::FindRecValue found..., Description: value==>5601"
"ERROR" 5928 "2015-11-02 18:17:33.879" "Severity: 2 (High), Code: HM3156, Source: SQLiteRecordset::TryOpen, Description: select * from hm_settings"
"ERROR" 5928 "2015-11-02 18:17:33.879" "Severity: 3 (Medium), Code: HM5015, Source: PropertySet::GetProperty_(), Description: The property usescriptserver could not be found."
|
|
|
|
|
Sorry, but I cannot figure what is going on here, or what is supposed to be going on. Which of the log messages actually identifies any error?
|
|
|
|
|
"select * from hm_dbversion" reports correct result.
but next "select * from hm_settings" report nothing.
If we change sQuery = "select * from hm_settings" directly, it reports proper result.
But it actually useless in practice, and i need to process the dynamical SQL commands in the service.
I can't find the reason and crashed with a barrier. Now I have a doubt in the timing of SQL commands.
I'm so sorry for your efforts, best regards!
|
|
|
|
|
I see references to my_settings and hm_settings , as well as hm_dbversion and my_dbversion ? Are these intentional?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Sorry, I tried to change it intentionally.
The problem was settled. I found that I was so idiot.
I had mistaken by using invalid Error Log function.
ErrorManager::Instance()->ReportError(ErrorManager::Critical, ...);
I'm very sorry to everybody.
And very thanks all of you who had offered kind advises.
|
|
|
|
|
Just noting that in general a windows service would not be used to "manage" a database.
A database might be a windows service (or more than one service.)
A management API would exist on one of those servers.
Then an application, not service, would use that API and present a interface, like a GUI, to a user. The interface could also be a command line console.
A service API that would support the above would support the following
1- A definition of a protocol, such as Rest or more generally http
2- Commands that are sent via the protocol and responses to those commands.
3- The API protocol would be a LAYER on top of the actual management code.
3a - Supporting 3 one should probably add logging.
4- Management layer.
At best from your code it looks something like 3. I suggest you look into learning how to use a logging API.
Additionally there are other aspects involved with getting a windows service to run, and those have nothing to do with the actual database problem. For example
A- Starting/stopping the service
B- Running with the correct user
Member 11967800 wrote: If I give a static command such as "select * from my_settings" instead of sQuery.c_str(), it operated properly, but it doesn't act when it receives a dynamic params.
That doesn't have anything to do with windows service. It has to do with how you implemented the code. At best this looks like 4 above and you should get it that to work BEFORE you attempt to do anything else.
|
|
|
|
|
Thank you for your kind advice.
The problem was in using bad logger function.
I misused it and it disturbed normal activity of my SQLiteDB engine.
Now everything is OK.
Thank you again.
|
|
|
|
|
intelstar venus wrote: The problem was in using bad logger function.
In general that should never happen.
A good logger should not normally impact an application if the logger fails.
|
|
|
|
|
how can i send integer ??
---help---
#include<stdio.h>
#include<string.h>
#include<sys/socket.h>
#include<arpa/inet.h>
int main(int argc , char *argv[])
{
int sock;
struct sockaddr_in server;
char message[1000] , server_reply[2000];
int a;
char r1;
sock = socket(AF_INET , SOCK_STREAM , 0);
if (sock == -1)
{
printf("impossible de creer une socket\n");
}
puts("Socket creer!!!! good job");
server.sin_addr.s_addr = inet_addr("127.0.0.1");
server.sin_family = AF_INET;
server.sin_port = htons( 8880 );
puts ("connection au serveur\n") ;
if (connect(sock , (struct sockaddr *)&server , sizeof(server)) < 0)
{
perror("peut pas connecter au serveur");
return 1;
}
puts("vous etnSes Connecté\n");
while(1)
{
printf("Enter votre nbres : ");
scanf("%d " ,&a );
if (( send(sock , (char * )& a , sizeof(&a) , 0) < 0) )
{
puts("l'envoie a ete echoué");
return 1;
}
if( recv(sock , (char *)& a , 2000 , 0) < 0)
{
puts("recv echoué");
break;
}
}
close(sock);
return 0;
}
#include<stdio.h>
#include<string.h>
#include<sys socket.h="">
#include<arpa inet.h="">
#include<unistd.h>
int main(int argc , char *argv[])
{
int socket_desc , client_sock , c , read_size,read_size1;
struct sockaddr_in server , client;
char client_message[2000];
int a;
char t ;
socket_desc = socket(AF_INET , SOCK_STREAM , 0);
if (socket_desc == -1)
{
printf("on peut pas creer la socket");
}
puts("Socket bien creer");
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
server.sin_port = htons( 8880);
if( bind(socket_desc,(struct sockaddr *)&server , sizeof(server)) < 0)
{
perror("bind. Error");
return 1;
}
puts("bind attaché");
listen(socket_desc ,3);
puts("attedez une connection...");
c = sizeof(struct sockaddr_in);
client_sock = accept(socket_desc, (struct sockaddr *)&client, (socklen_t*)&c);
if (client_sock < 0)
{
perror("accept failed");
return 1;
}
puts("Connection accepté");
if ( (read_size = recv(client_sock , (char *)&a , 2000 , 0)) > 0 )
{
write(client_sock , &a , sizeof(&a));
}
if(read_size == 0)
{
puts("Client disconnected");
fflush(stdout);
}
else if(read_size == -1)
{
perror("recv failed");
}
return 0;
}
<pre lang="c">
|
|
|
|
|
Your code already sends and receives an integer; what is the problem?
|
|
|
|
|
thank you Richard McCutchan, the problem is that I wanted to display the number at the server level. 
|
|
|
|
|
|
There are some errors in your. The first is the buffer size when sending an integer;
if (( send(sock , (char * )& a , sizeof(&a) , 0) < 0) )
The passed buffer size is wrong. It should be:
if (( send(sock , (char * )& a , sizeof(a) , 0) < 0) )
When reading replies, you probably want to read them into another buffer (as indicated by the size). So change
if( recv(sock , (char *)& a , 2000 , 0) < 0)
to
if( recv(sock , server_reply , sizeof(server_reply) , 0) < 0)
Similar for the server where you should first read an integer and then send the reply. So change this
if ( (read_size = recv(client_sock , (char *)&a , 2000 , 0)) > 0 )
to
if ( (read_size = recv(client_sock , (char *)&a , sizeof(a) , 0)) > 0 )
and send the reply afterwards.
|
|
|
|
|
merci beaucoup Jochen Arndt 
|
|
|
|
|
Hi,
im having trouble understanding this line of C code (XC32, pic32):
uint16_t Cur = 65535;
uint16_t Next = 14000;
uint32_t ResVal = 0;
ResVal = ((uint32_t)Cur + (uint32_t)Next);
I believe the C standard requires that some sort of integral promotion takes place here but the result is not 79535. Instead i get an overflown uint16_t result.
How can i add two uint16_t variables and get the correct uint32_t result?
|
|
|
|
|
That should work even without casting. For your example an optimising compiler would just assign 79535 to ResVal .
The XC32 compiler is gcc based. So I don't think that there is a compiler problem.
|
|
|
|
|
In addition to what Jochen said, sometimes looking at the disassembly is helpful.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
I tried your code with the simulator (I don't have a an actual PIC32 MCU) and I see (with a watch) the correct result.
|
|
|
|
|
First of all: Casting happens implicitly so you don't need to cast in this scenario.
Secondly: These types that you are specifying in non-standard types, so uint32_t could be defined as anything which will give you an incorrect result.
Thirdly: How to you check what the result is? Though debugging or though a print statement? The print statement could be wrong.
Fouth: Know your platform you writing the code for (its limitations and the standard it is using). Not necessarily that the pic32 uses the specific c standard which you are looking at.
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >></div>
|
|
|
|
|
It is possible to change the text of an menu item who has another branch menu ? I have tried classical solution:
pCmdUI->SetText(_T("&aaaa"));
but is working only on simple menu item ... if from this menu item go another menu items branch, the text have not change it ...
|
|
|
|
|