Execute an MS SQL Server stored procedure

Dear Friends
Xojo

Very grateful for your attention to resolve the following:

can someone provide me with some lines of code or some reference, to execute a stored procedure of MS SQL Server from Xojo.

Cordially,

Raul

does it return a row set ?
if so execute it using the same methods as you might execute raw SQL (executeSQL selectsql or sqlselect SQLexecute depending on what version of Xojo you’re using)

[quote=463672:@Norman Palardy]does it return a row set ?
if so execute it using the same methods as you might execute raw SQL (executeSQL or SQLexecute depending on what version of Xojo you’re using)[/quote]
Norman, I think you meant SelectSQL or SQLSelect if it returns rows.

Raul, the docs show how to setup access to the database. Then, depending on whether the stored procedure returns rows (records) or not, as Norman said, you would use SQLSelect or SQLExecute for the old API methods in Xojo, or SelectSQL or ExecuteSQL for the new API methods (Xojo 2019R2 or later). But note that the old API methods will continue to work in new Xojo versions for the foreseeable future.

1 Like

fixed
need more coffee

Infinite Thank you
Norman Palardy
Jay Madren

For your great help.

Below is an example to execute a stored procedure that does not return any records

Inventario: is the name of the database
productosins: name of the stored procedure
pDb: property of type MSSQLServerDatabase

Dim sql As String
sql = "inventario.dbo.productosins '001', 'RICE'"
App.pDb.SQLExecute (sql)
If App.pDb.Error Then
   MsgBox ("DB Error:" + App.pDB.ErrorMessage)
Else
   MsgBox ("Operation successful.")
End if

Cordially,

Raul Juarez Pulache

1 Like