Forum > Database
use .mdb database
EMN2404:
I converted my delphi software and got stuck with compiling. Some properties from Delphi are missing, like Connection, ComandText and Fields.
dtsConsult.Connection := MainForm.ADOConnectionExtract;
dtsConsult.CommandText := StrSQL;
Format('%9.4f', [DBGridConsult.Fields[DataCol].AsCurrency])
What am I supposed to use instead?
wp:
"ADOConnection"? Do you use Delphi's ADO components? They are not available in Lazarus. But you can use SQLDB for get access to the mdb database:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);begin //connection ODBCConnection1.Driver := 'Microsoft Access Driver (*.mdb, *.accdb)'; ODBCConnection1.Params.Add('DBQ=.\test.mdb'); ODBCConnection1.Params.Add('Locale Identifier=1031'); ODBCConnection1.Params.Add('ExtendedAnsiSQL=1'); ODBCConnection1.Params.Add('CHARSET=ansi'); ODBCConnection1.Connected := True; ODBCConnection1.KeepConnection := True; //transaction SQLTransaction1.DataBase := ODBCConnection1; SQLTransaction1.Action := caCommit; SQLTransaction1.Active := True; SQLQuery1.DataBase := ODBCConnection1; SQLQuery1.UsePrimaryKeyAsKey := False; SQLQuery1.SQL.Text := 'select * from Customers'; SQLQuery1.Open;end;
EMN2404:
Thanks, was able to compile, but when I ran the exe, it told me that it could not connect. I am attaching the captured image. What went wrong?
wp:
Is the mdb file in the same folder as the exe file?
jma_sp:
Hello WP.
Can you add ithis block of code in the wiki section about databases?. If it works might be useful for others.
Thanks
Navigation
[0] Message Index
[#] Next page