Query to MySQL from c# returns System.Byte[]
- by karthik
I am using the below SP to return the value of Generated Insert statement and it works fine when executed in Query browser.
When i try to get the value from C#, it give's me "System.Byte[]" as return value.
When i try to get the value from MySql query browser, it give's me return value as :
'insert into admindb.accounts values("54321","2","karthik2","karthik2","1");'
I guess the problem is with the single quotes of the returned value. Is it so ?
DELIMITER $$
DROP PROCEDURE IF EXISTS `admindb`.`InsGen` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `InsGen`(
in_db varchar(20),
in_table varchar(20),
in_ColumnName varchar(20),
in_ColumnValue varchar(20)
)
BEGIN
declare Whrs varchar(500);
declare Sels varchar(500);
declare Inserts varchar(2000);
declare tablename varchar(20);
declare ColName varchar(20);
set tablename=in_table;
# Comma separated column names - used for Select
select group_concat(concat('concat(\'"\',','ifnull(',column_name,','''')',',\'"\')'))
INTO @Sels from information_schema.columns where table_schema=in_db and table_name=tablename;
# Comma separated column names - used for Group By
select group_concat('`',column_name,'`')
INTO @Whrs from information_schema.columns where table_schema=in_db and table_name=tablename;
#Main Select Statement for fetching comma separated table values
set @Inserts=concat("select concat('insert into ", in_db,".",tablename," values(',concat_ws(',',",@Sels,"),');')
as MyColumn from ", in_db,".",tablename, " where ", in_ColumnName, " = " , in_ColumnValue, " group by ",@Whrs, ";");
PREPARE Inserts FROM @Inserts;
EXECUTE Inserts;
END $$
DELIMITER ;