执行OleDb.OleDbDataAdapter.Fill()的时候,如何让OleDbDataAdapter一次执行2条sql语句从而一下返回2个dataTable,
解决方案 »
- datagridview,有没有在行选择变化前的事件?
- inputPanel1.CurrentInputMethod = inputPanel1.InputMethods[0];
- 关于Enterprise Library GenericDatabase 连接的问题
- 打开一个project出现the project type is not supported by this installation 错误
- openFileDialog怎么取得选中文件的地址
- 菜鸟求救,
- 请问在C#中怎样对字符进行Base64编码?
- 关于DataSet使用的几个问题!!!!!!!!!!!!
- 各位老大/高手:配置文件应该放在什么目录下
- 有没有一个Form里面的所有控件的列表
- 可以用继承 Component类的方法写数据库访问操作类不????
- 請教大俠:怎麼樣在我們方本框中輸入這個格式“00.00%”
2:select * from table1 select * from table2
3:select * from table1;select * from table2
How do I use ExecuteDataset to return a DataSet containing multiple tables?
You can retrieve a DataSet containing multiple tables by creating a stored procedure that returns multiple rowsets (either by executing multiple SELECT statements or by making nested calls to other stored procedures), and executing it using the ExecuteDataset method.For example, suppose you have the following stored procedures in your database.CREATE PROCEDURE GetCategories
AS
SELECT * FROM Categories
GO
CREATE PROCEDURE GetProducts
AS
SELECT * FROM Products
You could create a master stored procedure that makes nested calls to these procedures, as illustrated in the following code sample.CREATE PROCEDURE GetCategoriesAndProducts
AS
BEGIN
EXEC GetCategories
EXEC GetProducts
END
Executing this master stored procedure with the ExecuteDataset method returns a single DataSet containing two tables; one containing the category data and the other containing the product data.Note The ExecuteDataset method does not provide a way to assign custom names to the tables returned. The first table is always numbered 0 and named Table, the second is numbered 1 and named Table1, and so on.
"select * from table2";System.Data.OleDb.OleDbDataAdapter daT = new System.Data.OleDb.OleDbDataAdapter(sql,con); daT.TableMappings.Add("Table","1");
daT.TableMappings.Add("Table1","2");
DataSet ds = new DataSet();
daT.Fill(ds);
ds裏會產生兩個表
这个应该可以的
select * from table1;select * from table2
用nextrecord
select * from table1;select * from table2
用nextrecord
但在其他數據庫,不知道是否支持這種批查詢方式。
但他們會有自己的批查詢方式。自己找找看看吧。
查一下,可不可以用两个表连成一个这样表。
不过我觉得做成这样的意义不大,而且就算能够成功,要在前台程序把这两个表分开,都有难度!
Sql Server可以!