Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I had a multi dimensional array of the following fields in a table.

IDno INt , ExtNo (Char 20). So my array look like as follows.

1,"AB200"
2,"CD400"
3,"BSC01" and like this.

I want to pass this array to stored procedure and i want update the SQL Server Table.

Can any one help me how to pass multi dimensional array to stored procedure. And if possible, please show me some sample code.


Regards
Ramesh

(Deleted email id)
Posted
Updated 15-Mar-10 19:50pm
v2

1 solution

HI,
well in this case the best I can suggest you is to create XML through string builder and pass it to sp.
You can do something like this:

StringBuilder twoD_Arrat = new StringBuilder();
            twoD_Arrat.Append("<Transaction>");


            for (int y = 0; y < obj.Length; y++)
            {
                twoD_Arrat.Append("<Row" + y + ">");
                for (int x = 0; x < obj[y].Length; x++)
                {
                    twoD_Arrat.Append("<Col" + x + ">");
                    twoD_Arrat.Append(obj[y][x]);
                    twoD_Arrat.Append("</Col" + x + ">");
                }
                twoD_Arrat.Append("</Row" + y + ">");
            }
            twoD_Arrat.Append("</Transaction>");


In Sp just take a XML parameter..and process the value..

I hope this would help :-)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900