开发者

How to return multiple result sets from a mysql database using a C#.NET Winform application

I have a Winform C#.NET application.

When i used SQL Server , then to return two result sets together, I passed two SELECT queries using a linebreak '\n' , but how to do it in mysql?

IN SQL SERVER i did this and it completed :

"SELECT ProductName FROM Products" +"\n" +"SELECT ProductID 开发者_开发百科FROM Products"

But how to do this in MySQL????


In MySQL this is impossible due to its limitations. Long time ago they've decided that it's unsafe to allow multiple queries in one batch. This was probably because MySQL was often used in conjunction with php and it was common to do simple SQL injection attacks simply by adding semicolon and injecting another query.

PS> I don't know if it applies to new versions of MySQL since something might have changed since I was using it (about 3 years ago).

PS> I would suggest using stored procedures to accomplish this task.

This would probably look sth like that:

CREATE PROCEDURE sample_procedure()
READS SQL DATA
BEGIN
  SELECT xxx FROM yyy;
  SELECT zzz FROM vvv;
END;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜