From Clomosy Docs

Revision as of 08:35, 22 August 2023 by ClomosyManager (talk | contribs) (Created page with "To connect to a SQL Server database using the DBSQLServerConnect component in Clomosy, you can follow these basic steps: * Set the SQL Server Connection String: First, you'll need to prepare the connection string that you'll use to connect to the SQL Server database. This string should include the name of the SQL Server, the database name, authentication credentials, and other connection details. Clomosy.DBSQLServerConnect(<span style="color:red">'SQL Server','server_...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

To connect to a SQL Server database using the DBSQLServerConnect component in Clomosy, you can follow these basic steps:

  • Set the SQL Server Connection String:

First, you'll need to prepare the connection string that you'll use to connect to the SQL Server database. This string should include the name of the SQL Server, the database name, authentication credentials, and other connection details.

Clomosy.DBSQLServerConnect('SQL Server','server_name','user_name','user_password','database_name',port);
  • Define the TUniQuery component:

To execute queries in SQL Server, you can use the TUniQuery component. It is defined within your application.

var
LocalQ:TUniQuery;
  • Specify the SQL query you want to run:
LocalQ := Clomosy.DBSQLServerQueryWith('SELECT model AS Product_Model FROM OperatingSystem');
  • To go to the first record in the query's result set:
LocalQ.First;
  • To advance to the next record in the data access component:
LocalQ.Next;

Example:

Var   
MyForm:TclForm;
LocalQ:TUniQuery;

begin 

Clomosy.DBSQLServerConnect('SQL Server','server_name','user_name','user_password','database_name',port);
LocalQ := Clomosy.DBSQLServerQueryWith('SELECT model AS Product_Model FROM OperatingSystem');
LocalQ.First;
MyForm := TclForm.Create(Self);  
with LocalQ do
begin
  While NOT EOF Do
  Begin
    ShowMessage(FieldByName('Product_Model').AsString);
    Next;
  End;
end;

MyForm.Run;
end;