Recent

Author Topic: Error Project MsCompany raised Exception Class 'External:SIGSECV'.  (Read 2546 times)

Animez1

  • Newbie
  • Posts: 5
I have Error when i click for save button to insert data

here is my code:

    SqlCompany.SQL.Clear;
    SqlCompany.SQL.Add('insert into Ms_Company (CompanyID,CompanyName,Address,Director,Occupation,Nationality,Commodity,MineLocation,Village,District,City,Province,AreaCode,Wide,Note,del) ');
    SqlCompany.SQL.Add('values (:CompanyID,:CompanyName,:Address,:Director,:Occupation,:Nationality,:Commodity,:MineLocation,:Village,:District,:City,:Province,:AreaCode,:Wide,:Note,:del)');
    SqlCompany.Params.ParamByName('CompanyID').AsString:=trim(ci.Text);
    SqlCompany.Params.ParamByName('CompanyName').AsString:=trim(cn.Text);
    SqlCompany.Params.ParamByName('Address').AsString:=trim(A.Text);
    SqlCompany.Params.ParamByName('Director').AsString:=trim(Dr.Text);
    SqlCompany.Params.ParamByName('Occupation').AsString:=trim(Oc.Text);
    SqlCompany.Params.ParamByName('Nationality').AsString:=trim(N.Text);
    SqlCompany.Params.ParamByName('Commudity').AsString:=trim(Co.Text);
    SqlCompany.Params.ParamByName('MineLocation').AsString:=trim(ML.Text);
    SqlCompany.Params.ParamByName('Village').AsString:=trim(V.Text);
    SqlCompany.Params.ParamByName('District').AsString:=trim(D.Text);
    SqlCompany.Params.ParamByName('City').AsString:=trim(C.Text);
    SqlCompany.Params.ParamByName('Province').AsString:=trim(P.Text);
    SqlCompany.Params.ParamByName('AreaCode').AsString:=trim(AC.Text);
    SqlCompany.Params.ParamByName('Wide').AsString:=trim(W.Text);
    SqlCompany.Params.ParamByName('Note').AsFloat:=strtofloat(trim(Nw.Text));
    SqlCompany.Params.ParamByName('del').AsString:='F';
    SqlCompany.ExecSQL;   

Please help me to solve this problem.

Thanks

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Error Project MsCompany raised Exception Class 'External:SIGSECV'.
« Reply #1 on: February 20, 2018, 10:32:24 am »
Probably one of the identifiers you use (like ci, a,dr or sqlcompany) is not created/allocated.

The fragment is too short to really find out what is wrong.

Animez1

  • Newbie
  • Posts: 5
Re: Error Project MsCompany raised Exception Class 'External:SIGSECV'.
« Reply #2 on: February 20, 2018, 11:05:06 am »
i think  the identifiers that i used already been created/allocated

here i share the project

https://drive.google.com/open?id=1My1qXZgXJ8pzq2hcGZ7OnLt5c97Q8nSQ

thanks

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Error Project MsCompany raised Exception Class 'External:SIGSECV'.
« Reply #3 on: February 20, 2018, 11:09:27 am »
I have Error when i click for save button to insert data
It would be useful if you shared the Error-message itself too (and on which line it occurs).

Also, I see a lot of TEdits in your program.
Do you know about the existence of TDBEdit?
It's a TEdit which directly links to the DB-component so there is no need to assign the text each time.

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Error Project MsCompany raised Exception Class 'External:SIGSECV'.
« Reply #4 on: February 20, 2018, 11:26:13 am »
I found your problem.
When changing the SqlCompany.SQL you should ALWAYS make sure the dataset is NOT active.

So:
Code: Pascal  [Select][+][-]
  1.     SqlCompany.Active := false; // <-- add this line
  2.     SqlCompany.SQL.Clear;
  3.     SqlCompany.SQL.Add('insert into Ms_Company (CompanyID,CompanyName,Address,Director,Occupation,Nationality,Commodity,MineLocation,Village,District,City,Province,AreaCode,Wide,Note,del) ');
  4.  

Another problem in your code is this:
Code: Pascal  [Select][+][-]
  1.     SqlCompany.SQL.Add('values (:CompanyID,:CompanyName,:Address,:Director,:Occupation,:Nationality,:Commodity,:MineLocation,:Village,:District,:City,:Province,:AreaCode,:Wide,:Note,:del)');
  2.     //...
  3.     SqlCompany.Params.ParamByName('Commudity').AsString:=trim(Co.Text);
  4.  
You have Commodity in the values but are trying to fill Commudity.

Next there is still an error but try to fix this first.

Also, look at the TDBEdit component.
If you use that instead of TEdit you don't need to assign the TEdit values each record-change and you don't need to put the values back with parambyname. You can just use SqlCompany with the TDBEdit and the insert is done automatically. Your code can be reduced by almost 90%.

Animez1

  • Newbie
  • Posts: 5
Re: Error Project MsCompany raised Exception Class 'External:SIGSECV'.
« Reply #5 on: February 21, 2018, 04:35:48 am »
Thanks for ur help i will check its again

Animez1

  • Newbie
  • Posts: 5
Re: Error Project MsCompany raised Exception Class 'External:SIGSECV'.
« Reply #6 on: February 21, 2018, 05:56:24 am »
i change the code to

    SqlCompany.SQL.Clear;
    SqlCompany.SQL.Add('insert into Ms_Company values ( ');
    SqlCompany.SQL.Add(''''+trim(ci.Text)+''','''+trim(cn.Text)+''','''+trim(a.Text)+''','''+trim(dr.Text)+''','''+trim(oc.Text)+''', ');
    SqlCompany.SQL.Add(''''+trim(N.Text)+''','''+trim(co.Text)+''','''+trim(ml.Text)+''','''+trim(v.Text)+''','''+trim(d.Text)+''', ');
    SqlCompany.SQL.Add(''''+trim(c.Text)+''','''+trim(p.Text)+''','''+trim(ac.Text)+''','''+trim(w.Text)+''',');
    SqlCompany.SQL.Add(''''+trim(Nw.Text)+''',''F'')');
    SqlCompany.ExecSQL;


and Success

Thanks Rvk and Marcov for ur help

Animez1

  • Newbie
  • Posts: 5
Re: Error Project MsCompany raised Exception Class 'External:SIGSECV'.
« Reply #7 on: February 21, 2018, 06:04:12 am »
No error but... the data not saved... please help

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Error Project MsCompany raised Exception Class 'External:SIGSECV'.
« Reply #8 on: February 21, 2018, 11:41:50 am »
No error but... the data not saved... please help
You also need to commit the transaction. Or set the default Action of the transaction to something other than caRollback. Otherwise your changes are rolled back when you end the program.


 

TinyPortal © 2005-2018