نمایش نتایج 1 تا 5 از 5

نام تاپیک: مشكل در اجراي متد در برنامه تحت شبكه(method. .... not supported by automation object)

Hybrid View

پست قبلی پست قبلی   پست بعدی پست بعدی
  1. #1
    کاربر دائمی آواتار ROSTAM2
    تاریخ عضویت
    اسفند 1390
    محل زندگی
    فارس
    پست
    1,677

    نقل قول: مشكل در اجراي متد در برنامه تحت شبكه(method. .... not supported by automation object)

    سلام.


    program ProjectMysqlADO;


    {$APPTYPE CONSOLE}


    uses
    ActiveX,
    DB,
    ADODB,
    SysUtils;


    const
    //the connection string
    StrConnection='Driver={MySQL ODBC 3.51 Driver};Server=%s;Database=%s;User=%s; Password=%s;Option=3;';




    var
    AdoConnection : TADOConnection;


    procedure SetupConnection(DataBase:String);//Open a connection
    begin
    Writeln('Connecting to MySQL');
    AdoConnection:=TADOConnection.Create(nil);
    AdoConnection.LoginPrompt:=False;//dont ask for the login parameters
    AdoConnection.ConnectionString:=Format(StrConnecti on,['your_server',DataBase,'your_user','your_password']);
    AdoConnection.Connected:=True; //open the connection
    Writeln('Connected');
    end;


    procedure CloseConnection;//Close an open connection
    begin
    Writeln('Closing connection to MySQL');
    if AdoConnection.Connected then
    AdoConnection.Close;
    AdoConnection.Free;
    Writeln('Connection closed');
    end;


    procedure CreateDatabase(Database:string);
    begin
    Writeln('Creating Database '+database);
    AdoConnection.Execute('CREATE DATABASE IF NOT EXISTS '+Database,cmdText);
    Writeln('Database '+database+' created');
    end;


    procedure CreateTables;
    begin
    Writeln('Creating Tables');
    AdoConnection.Execute(
    'CREATE TABLE IF NOT EXISTS customers ('+
    'id INT,'+
    'name VARCHAR(100),'+
    'country VARCHAR(25) )',cmdText);
    Writeln('Tables Created');
    end;




    procedure DeleteData;
    begin
    Writeln('Deleting dummy data');
    AdoConnection.Execute('DELETE FROM customers');
    Writeln('Data deleted');
    end;


    procedure InsertData;


    Procedure InsertReg(id:integer;name,country:string);
    var
    ADOCommand : TADOCommand;
    begin
    ADOCommand:=TADOCommand.Create(nil);
    try
    ADOCommand.Connection:=AdoConnection;
    ADOCommand.Parameters.Clear;
    ADOCommand.CommandText:='INSERT INTO customers (id,name,country) VALUES (:id,:name,:country)';
    ADOCommand.ParamCheck:=False;
    ADOCommand.Parameters.ParamByName('id').Value := id;
    ADOCommand.Parameters.ParamByName('name').Value := name;
    ADOCommand.Parameters.ParamByName('country').Value := country;
    ADOCommand.Execute;
    finally
    ADOCommand.Free;
    end;
    end;


    begin
    Writeln('Inserting Data');
    InsertReg(1,'Lilian Kelly','UK');
    InsertReg(2,'John and Sons','USA');
    InsertReg(3,'William Suo','USA');
    InsertReg(4,'MARCOTEC','UK');
    Writeln('Data Inserted');
    end;


    procedure ReadData;
    var
    AdoQuery : TADOQuery;
    begin
    AdoQuery:=TADOQuery.Create(nil);
    try
    AdoQuery.Connection:=AdoConnection;
    AdoQuery.SQL.Add('SELECT * FROM customers');
    AdoQuery.Open;
    while not AdoQuery.eof do
    begin
    Writeln(format('%s %s %s',[AdoQuery.FieldByname('id').AsString,AdoQuery.Field Byname('name').AsString,AdoQuery.FieldByname('coun try').AsString]));
    AdoQuery.Next;
    end;
    finally
    AdoQuery.Free;
    end;
    end;


    begin
    CoInitialize(nil); // call CoInitialize()
    try
    Writeln('Init');
    try
    SetupConnection('mysql'); //first will connect to the mysql database , this database always exist
    CreateDatabase('Mydb'); //now we create the database
    CloseConnection; //close the original connection
    SetupConnection('Mydb'); //open the connection pointing to the Mydb database
    CreateTables; //create a sample table
    DeleteData; //Delete the dummy data before insert
    InsertData; //insert a dummy data
    ReadData; //read the inserted data
    CloseConnection; //close the connection
    except
    on E : Exception do
    Writeln(E.Classname, ': ', E.Message);
    end;
    Readln;
    finally
    CoUnInitialize; // free memory
    end;
    end.


    https://www.cdata.com/kb/tech/sql-odbc-delphi.rst


    SqlClient Data Access Components for Delphi - CrystalNet Technologies LTD (crystalnet-tech.com)

    https://www.thoughtco.com/sql-in-delphi-4092571

    https://feb.unpas.ac.id/fe_app/index...ARoaWREUWQgdHA
    آخرین ویرایش به وسیله ROSTAM2 : دوشنبه 11 مهر 1401 در 08:59 صبح

تاپیک های مشابه

  1. سوال: دریافت سایز فایل قبل از آپلود و خطای Automation Server Can't create object
    نوشته شده توسط احمد سامعی در بخش JavaScript و Framework های مبتنی بر آن
    پاسخ: 3
    آخرین پست: شنبه 06 آبان 1391, 16:55 عصر
  2. سوال: error : "The object doesn't contain the Automation object 'Object x
    نوشته شده توسط nedanass در بخش Access
    پاسخ: 0
    آخرین پست: چهارشنبه 14 اردیبهشت 1390, 11:41 صبح
  3. Automation server can't create object
    نوشته شده توسط bahram_ariana در بخش طراحی وب (Web Design)
    پاسخ: 1
    آخرین پست: سه شنبه 18 آبان 1389, 21:58 عصر
  4. ایجاد یک خطای جدید Automation server can't create object
    نوشته شده توسط ashena29 در بخش ASP.NET Web Forms
    پاسخ: 5
    آخرین پست: سه شنبه 09 اسفند 1384, 08:56 صبح

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •