Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# .NET MySQL
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:
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:
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 15-Aug-11 22:25pm
Edited 18-Aug-11 22:51pm
v10
Comments
unknowndentified10111 at 19-Aug-11 4:51am
   
No one is answering... :(
Simon_Whale at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The MySQL Documentation might be a good place to start
 
MySQL XML functions[^]
  Permalink  
Comments
unknowndentified10111 at 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 at 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 at 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)



Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 19 Aug 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100