Passing DataTable to SP with SQL Server 2008 & .NET 1.1

mte01 used Ask the Experts™
Hey experts,

we have a SP on SQL Server 2008 that takes a user-defined table type (a 2008 feature). Of course from .NET 4.0 (Visual Studio 2010), I'm able to call it normally passing to it a .NET DataTable.
Now the issue is that I need to call it from a .NET 1.1 application (VS 2003); is there anyway this can be done using some add-in?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
have you tried passing .net datatable . I think that will work

Found a different way to go about doing it. This way uses the System.Data.SqlClient libraries to create a connection to the database, specify the stored procedure name, and then pass a parameter in as a DataTable that serves as the SQL Server user-defined table type.

using (SqlConnection conn = new SqlConnection(connStr)) {
    SqlCommand cmd = conn.CreateCommand();
    cmd.CommandType = System.Data.CommandType.StoredProcedure;
    cmd.CommandText = "dbo.usp_Test";
    cmd.Parameters.AddWithValue("@ids", dt);

    using (SqlDataReader sqlReader = cmd.ExecuteReader()) {
        DataTable retTbl = new DataTable();



.NET 1.1 does not have AddWithValue; it has an overload of .Add that takes name & value (without dbtype); we tried this, but it errored out at the .Add command with:

Index (zero based) must be greater than or equal to zero and less than the size of the argument list

You could try:

SqlParameter param = New SqlParameter();
param = cmd.Parameters.Add("@ids", SqlType.Structured);
param.Value = "your dataTable";

If you receive the message "sqlDBType.Structured" is not part of System.Data.SqlDbType

Then you may need to install a more recent version the the .net framework, because .Structured was added after 2003.
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.



This was my point in the 1st place :) I cannot upgrade my current project from 1.1 because it's very large, and I need - if possible - some add-on library that would allow me to do this SP call to SQL Server 2008
Apparently, there's no way to do it, but using .NET 3.5 (VS 2008) - it can't be done using .NET 1.1


Came down to it after research

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial