Call a stored procedured in SQL

Understanding basics of 1C:Enterprise platform. To start working with 1C:Enterprise platform visit Getting started page

#1
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Apr 10, 2017
Company:

Hello 1C,

I have some troubles with calling a stored procedure in SQL from 1C. I've followed this topic https://1c-dn.com/forum/forum5/topic1790/?sphrase_id=134114#message11634. My connection is totally fine but the system could not find the Stored Procedure in SQL and I'm sure that name of SP is exactly. The name of Stored Procedure is SelectAll without parameters.

Download 1.png (53.23 KB)
 
#2
People who like this:0Yes/0No
Administrator
Rating: 6
Joined: Oct 3, 2019
Company:

Hi Anh Bui!

Do you use MS SQL in your work?

If you call a stored procedure in the SQL console - does it work?

Aleksandr

 
#3
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Apr 10, 2017
Company:

Hi Aleksandr,

I ran "EXEC SelectAll" in SQL and it works.

 
#4
People who like this:0Yes/0No
Administrator
Rating: 6
Joined: Oct 3, 2019
Company:

Please show me your 1C code...

 
#5
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Apr 10, 2017
Company:

Here is my code

Code
ConnectionParameters = ExternalDataSources.StoreProcedured.GetCommonConnectionParameters();
   ConnectionParameters.ConnectionString = "DRIVER={SQL Server};SERVER=SRV-TR-KYTHU\SQL2014;";
   ConnectionParameters.DBMS = "SyncNano2Tr";
   ConnectionParameters.UserName = "sa";
   ConnectionParameters.Password = "sql2014@";
   ConnectionParameters.StandardAuthentication = True;
   
   ExternalDataSources.StoreProcedured.SetCommonConnectionParameters(ConnectionParameters);
   ExternalDataSources.StoreProcedured.Connect();
      
   ExternalDataSources.StoreProcedured.dbo_SelectAll();



And the link to SP

Download 1.png (92.8 KB)
 
#6
People who like this:0Yes/0No
Administrator
Rating: 6
Joined: Oct 3, 2019
Company:

Hi Anh Bui!

Your "ConnectionString" should look like this:

Code
ConnectionParameters.ConnectionString = "DRIVER={SQL Server};SERVER=SRV-TR-KYTHU\SQL2014;DATABASE=SyncNano2Tr";


That is, you should add the name of your database to it: "DATABASE=SyncNano2Tr".

Please try this code.

Aleksandr

 
#7
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Apr 10, 2017
Company:

Thank you so much Aleksandr, I got it.

Have a nice day!

 
Subscribe
Be the first to know tips & trick on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.