?
Solved

Delphi TSQL Connection runtime creating

Posted on 2014-07-31
1
Medium Priority
?
1,190 Views
Last Modified: 2014-08-01
i'll trying to create tsqlconnection at runtime, but i get this error :
SQLConnectionProperty required for this operation.
what i am doing wrong?


procedure grid_select();
var
  fotabla_grid_conn_msh   : TSQLConnection;
  MSHQuery_fotabla_grid : TSQLQuery;

begin
create_connection( fotabla_grid_conn_msh, f_foablak );
MSHQuery_fotabla_grid:= TSQLQuery.Create(self);
MSHQuery_fotabla_grid.SQLConnection := fotabla_grid_conn_msh;
MSHQuery_fotabla_grid.Name := 'MSHQuery_fotabla_grid';
end;

procedure Tf_foablak.create_connection ( P_CONNECTION_NAME : TSQLConnection; P_FORM : TForm );
begin
    P_CONNECTION_NAME:= TSQLConnection.Create(P_FORM);
            P_CONNECTION_NAME.ConnectionName := P_CONNECTION_NAME.ConnectionName;
            P_CONNECTION_NAME.DriverName := 'MySQL';
    P_CONNECTION_NAME.Params.Clear;
            P_CONNECTION_NAME.LoginPrompt := False;
            P_CONNECTION_NAME.Params.Add('DriverName=MySQL');
            P_CONNECTION_NAME.Params.Add('HostName='+f_foablak.ComboBox1.Text);
            P_CONNECTION_NAME.Params.Add('Database=microshop');
            P_CONNECTION_NAME.Params.Add('User_Name=rt');
            P_CONNECTION_NAME.Params.Add('Password=MiC85HarV01');
            P_CONNECTION_NAME.Params.Add('BlobSize=-1');
            P_CONNECTION_NAME.Params.Add('ErrorResourceFile=');
            P_CONNECTION_NAME.Params.Add('LocaleCode=0000');
            P_CONNECTION_NAME.Params.Add('Compressed=False');
            P_CONNECTION_NAME.Params.Add('Encrypted=False');
            P_CONNECTION_NAME.Params.Add('Use Procedure Bodies=False');
            P_CONNECTION_NAME.Params.Add('character_set_client = utf8');
            P_CONNECTION_NAME.Params.Add('character_set_connection = utf8');
            P_CONNECTION_NAME.Params.Add('character_set_results = Latin2');
            P_CONNECTION_NAME.Params.Add('CharSet=WIN1252');
            P_CONNECTION_NAME.Params.Add('ServerCharSet=UTF8');
            P_CONNECTION_NAME.Params.Add('UseUnicode=True');

            P_CONNECTION_NAME.GetDriverFunc := 'getSQLDriverMYSQL';
            P_CONNECTION_NAME.KeepConnection := True;
            P_CONNECTION_NAME.LibraryName := 'dbxmys.dll';
            P_CONNECTION_NAME.LoadParamsOnConnect := False;
            P_CONNECTION_NAME.VendorLib := 'libmysql.dll';

            P_CONNECTION_NAME.Connected := True;


end;
0
Comment
Question by:RT_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 27

Accepted Solution

by:
Sinisa Vuk earned 2000 total points
ID: 40234029
you should use var keyword - because your newly created object will get new instance:

...
procedure Tf_foablak.create_connection (var P_CONNECTION_NAME : TSQLConnection; P_FORM : TForm );

..

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question