Click here to Skip to main content
15,849,594 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi All,

Please help me.
I need to pass a DataSet in MySQL.

It is feasible in MSSQL since I already tried it.

I do it like this in MSSQL:
In my c# code:
C#
DataSet ds = new DataSet("Uploads");
ds.Tables.Add(new DataTable("exclution"));
SqlCommand oCommand = new SqlCommand("spUpdateDatabase", oConnection);
oCommand.CommandType = CommandType.StoredProcedure;
oCommand.Parameters.AddWithValue("@LocalDatabase", ds.GetXml());

And my stored procedure would be like this:
SQL
DECLARE @index int
    
BEGIN TRANSACTION

EXEC sp_xml_preparedocument @index OUTPUT, @LocalDatabase

        INSERT INTO		        exclution
	SELECT			        @BranchCode
				,	ExclutionID
				,	InsuredID
				,	InsuredRelationship
				,	ExclutionDiagnoses
	FROM	OPENXML(@index, 'Uploads/exclution')
	WITH	(	ExclutionID          int         'ExclutionID'
		  ,	InsuredID            int         'InsuredID'
		  ,	InsuredRelationship  varchar(45) 'InsuredRelationship'
		  ,	ExclutionDiagnoses   varchar(100)'ExclutionDiagnoses')

EXEC sp_xml_removedocument @index  
     
IF (@@ERROR <> 0)
BEGIN
	ROLLBACK TRANSACTION
	SELECT 1
END
ELSE
BEGIN
	COMMIT TRANSACTION
	SELECT 0
END


But I cant find a way to do it in MySQL.
Any help would be greatly appreciated.

Thanks in advance.
Posted
Updated 18-Aug-11 23:51pm
v10
Comments
unknowndentified10111 19-Aug-11 4:51am    
No one is answering... :(
Simon_Whale 19-Aug-11 5:14am    
For me personally I can't see a way to implement what you are asking for in the same manner as SQL Server does. I think you may have to change your approach. maybe someone else has a different idea for you

1 solution

The MySQL Documentation might be a good place to start

MySQL XML functions[^]
 
Share this answer
 
Comments
unknowndentified10111 16-Aug-11 5:02am    
I already looked into that. But the xml function of MySql can't return a Table Set. It only return a scalar value. What I need is like what I do in my MSSQL stored procedure. But thanks anyways..
Simon_Whale 16-Aug-11 5:08am    
dont know if this will help?

http://www.lampdev.net/programming/mysql/mysql-stored-procedure-in-parameter-array-data.html

as I dont know how big your dataset that you want to pass in, someone here has found a way to pass in a parameter array
unknowndentified10111 16-Aug-11 20:18pm    
That would'nt work for me, the parameter array was only always a single dimension array, If I'm going to pass a dataset, I atleast need a two dimension array for rows and columns. Thanks for the reply. But I still need help.....

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