Lazarus Free Pascal / Delphi - RunError 211

百般思念 提交于 2019-12-13 18:29:43

问题


I'm trying to connect my Windows XP program (Lazarus) to my Ubuntu postgres server.

When the Lazarus program runs, it seems to compile fine but I get this error:

Project ... raised exception class 'RunError(211)'.

Then it terminates execution (and I don't see any output), and opens up a file customform.inc. In that file, it shows a procedure procedure TCustomForm.DoCreate; where it highlights a line: if Assigned(FOnCreate) then FOnCreate(Self);

I believe this is one of the system's files.

I never get to see any output. What could this be? Thanks!

MORE INFO:

I've narrowed down the error to this line:

  dbQuery_Menu.SQL.Text:='Select * From "tblMenus"';

  dbQuery_Menu.Open;

the exception is triggered when the OPEN statement gets executed.

BTW, dbQuery_Menu is defined as a TSQLQuery component.

Clueless! :(


回答1:


After nearly 5 days I found the answer. Many thanks to all thos e ho have contributed with their ideas ESPECIALLY RRUZ, RBA and Guillem Vicens. there are other related posts all connected to getting the FIRST Lazarus program working with PostgreSQL.

Summary.

  1. The biggest mistake I made here was that I used the TSQLConnection component. Don't do this. Instead use the TPQConnection.

  2. Everything is done through code. We're not using any draggable components from the top tab.

  3. Don't rely on the Lazarus docs (wiki) at least for working with PG DBs.. It is outdated. Some of the examples can be pretty misleading.

  4. Make sure that fields have some default values. For example, if a Boolean field has no true or false (t/f) set, this may lead to errors.

And that's it! I hope many postgres+Lazarus newbies will find this useful.




回答2:


Run error 211 appears when you try to call an abstract method. Check this link from more information on FreePascal/Lazarus runtime errors.

Since you say all is done by code and you have no visual components, the problem probably lies in your code trying to use an ancestor component which has not overriden the Open method. You should be able to solve this by using the correct descendant component.

Another possibility, although I would strongly recommend to avoid this one, is to override the Open method yourself. It should be avoided because if you are using an ancestor component then you probably would have to override more abstract methods.

HTH




回答3:


From here - http://www.network-theory.co.uk/docs/postgresql9/vol2/SQLSTATEvsSQLCODE.html - -211 (ECPG_CONVERT_BOOL) This means the host variable is of type bool and the datum in the database is neither 't' nor 'f'. (SQLSTATE 42804)



来源:https://stackoverflow.com/questions/13138271/lazarus-free-pascal-delphi-runerror-211

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!