passing Record into Table valued parameters

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
hmdsadeghian
Posts: 5
Joined: Sat 03 Oct 2009 13:21

passing Record into Table valued parameters

Post by hmdsadeghian » Mon 28 May 2012 12:30

Hi everybody.
How can i pass record type into table valued parameters with TStoredproc?
I'm using SDAC 6.1.4 for Delphi XE2.

Thanks

AndreyZ

Re: passing Record into Table valued parameters

Post by AndreyZ » Tue 29 May 2012 09:10

Hello,

Please read the "Using Table-Valued Parameters" article of the SDAC documentation. It describes the way of using the TMSStoredProc component to work with Table-Valued Parameters.

Lithium™
Posts: 42
Joined: Wed 23 Jun 2010 06:42

Re: passing Record into Table valued parameters

Post by Lithium™ » Fri 21 Dec 2012 07:27

Hello, AndreyZ.

Do I have to install every time new version of SDAC to refresh last documentation? Is there any way to download latest documentation without reinstalling?

Thanks.

AndreyZ

Re: passing Record into Table valued parameters

Post by AndreyZ » Fri 21 Dec 2012 09:00

You can download the latest version of the SDAC documentation in the CHM and PDF formats at http://www.devart.com/sdac/download.html

Lithium™
Posts: 42
Joined: Wed 23 Jun 2010 06:42

Re: passing Record into Table valued parameters

Post by Lithium™ » Fri 21 Dec 2012 10:14

I've got it.

Code: Select all

MSTableData.TableTypeName := 'DeptTableType';
MSTableData.Open;
MSTableData.Append;
MSTableData.Fields[0].AsString := 'ACCOUNTING';
MSTableData.Fields[1].AsString := 'NEW YORK';
MSTableData.Post;

MSStoredProc.StoredProcName := 'SP_InsertDept';
MSStoredProc.PrepareSQL;
MSStoredProc.ParamByName('TVP').AsTable := MSTableData.Table;
MSStoredProc.ExecProc;
MSTableData.Close;
If a stored procedure requires two or more table-valued parameters, should I create and open several TMSTableData instances for each of them?

AndreyZ

Re: passing Record into Table valued parameters

Post by AndreyZ » Fri 21 Dec 2012 12:06

If a stored procedure requires two or more table-valued parameters, should I create and open several TMSTableData instances for each of them?
Yes.

hmdsadeghian
Posts: 5
Joined: Sat 03 Oct 2009 13:21

Re: passing Record into Table valued parameters

Post by hmdsadeghian » Wed 11 Sep 2013 18:55

Hi again.
I'm using TMSTABLEDATA to work with Table-Valued parameter .
When i click on the TableTypeName Drop Down,i get the error "Table Valued parameter is not supported by SQL Server" .
If typing Table-Valued Parameter name in the TableTypeName and avtice the connection,i get the error "Table Does not Exist".

I'm using Delphi 2010 And SQL Server 2012.
Sdac Version is = 6.7.14

Thanks for Advance.

AndreyZ

Re: passing Record into Table valued parameters

Post by AndreyZ » Thu 12 Sep 2013 09:46

Table-Valued Parameters are supported since SQL Server 2008 and only using SQL Native Client 10 or higher. As you are using SQL Server 2012, the problem occurs because you are using not the correct version of the provider. To solve the problem, you should set the TMSConnection.Options.Provider property to prAuto or prNativeClient. Also, make sure you have SQL Native Client 10 or 11 installed on your computer.

hmdsadeghian
Posts: 5
Joined: Sat 03 Oct 2009 13:21

Re: passing Record into Table valued parameters

Post by hmdsadeghian » Thu 12 Sep 2013 11:28

Thanks.

AndreyZ

Re: passing Record into Table valued parameters

Post by AndreyZ » Thu 12 Sep 2013 12:13

If any other questions come up, please contact us.

Post Reply