Desktop version

Main > Forum > 1C:Enterprise Platform > Studying 1C:Enterprise platform > Call a stored procedured in SQL

Forum

Search UsersRules
Call a stored procedured in SQL
#1
Just came
Points:: 0
Joined:: Apr 10, 2017

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.

Profile
#2
Administrator
Points:: 0
Joined:: Oct 3, 2019

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

Profile
#3
Just came
Points:: 0
Joined:: Apr 10, 2017

Hi Aleksandr,

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

Profile
#4
Administrator
Points:: 0
Joined:: Oct 3, 2019

Please show me your 1C code...

Profile
#5
Just came
Points:: 0
Joined:: Apr 10, 2017

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

Profile
#6
Administrator
Points:: 0
Joined:: Oct 3, 2019

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

Profile
#7
Just came
Points:: 0
Joined:: Apr 10, 2017

Thank you so much Aleksandr, I got it.

Have a nice day!

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.