Pregunta

I'm trying to connect to my postgresql database using Lazarus pascal. I get this error towards the end of compilation (F9).

mainform.pas(112,35) Error: Wrong number of parameters specified for call to "Create"

Here's my code:

  dbConn:= TSQLConnection.Create(nil);    
  dbConn.HostName := '<IP goes here>';    
  dbConn.DatabaseName:= 'dbMydb';    
  dbconn.UserName:='me';    
  dbConn.Password:='pas';    
  dbConn.Open;

  //Bind the Transaction AND Query components to the DB connection

  dbQuery_Menu := TSQLQuery.Create; //This is the line with the error    
  dbQuery_Menu.Database := dbConn;    
  dbQuery_Menu.Transaction := dbTrans ;

I'm really exhausted trying to figure this out... Any help please...

The above code was adapted from here.

¿Fue útil?

Solución

It seems which the documentation is outdated, the TSQLQuery descends from the TCustomSQLQuery class where the constructor is defined like

 constructor Create(AOwner : TComponent); override; 

So you need to modify your code like this

dbQuery_Menu :=TSQLQuery.Create(nil); 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top