Options

Access Stored Procedure through ADO

hedayahedaya Member Posts: 11
Hi All,
Could anybody please let me know how to access stored procedure (for INSERT & Getting Recordset back) from the SQL Server using ADO object.

We are using Navision SQL Server package...But I would like to optimize some of Queries with Stored procedure

Any documents or working code snapshots will be appreciated...!

Thanks,
Hed

Comments

  • Options
    TbiTbi Member Posts: 33
    A simple ADO codeexample :
    VAR:
    adoConnection : Automation - 'Microsoft ActiveX Data Objects 2.8 Library'.Connection	
    adoRS : Automation - 'Microsoft ActiveX Data Objects 2.8 Library'.Recordset	
    sSql : Text 100
    
    
    
    CREATE(adoConnection);
    CREATE(adoRS);
    
    sSql := 'YOUR SQL STATEMENT';
    
    adoConnection.ConnectionString := 'Driver={SQL Server};Server=SERVERNAME;Database=DBNAME                                  ;Uid=USERNAME;Pwd=PASSWORD;';
    adoConnection.Open();  
    
    adoRS := adoConnection.Execute(sSql);
    
    adoConnection.Close();
    
  • Options
    hedayahedaya Member Posts: 11
    Thanks Tbi...
    Appreciated!
    Is there a way to manage the similar Code base to support Navision DB and SQL DB using ADO...I guess not...But I would like to see anymore options...

    thanks,
    Hed
  • Options
    kongsterkongster Member Posts: 4
    I have the same problem.

    In the ADO example, is sSql a stored procedure? How do I send parameters? For instance, I have a stored procedure calles TestStoredProcedures which takes 4 parameters. Should I write

    sSql := 'TestStoredProcedures'

    and what do I do with the parameters? Or is sSql an actual sql statement?

    I'm afraid I need very detailed information as this is very new to me. 8-[ Thanks
  • Options
    itspeteritspeter Member Posts: 105
    sSql:='EXEC StoreProcName ''eat mibuso'', ''sleep mibuso'', ''sleep mibuso'', ''ask mibuso''';
    

    sSql is the actual sql statement.

    Or can also be as below: -
    sSql:=STRSUBSTNO('EXEC StoreProcName ''%1'',''%2'',''%3'',''%4''', Param1, Param2, Param3, Param4);
    
    Regards,
    Peter Ng
Sign In or Register to comment.