using System;
using System.Data;
using System.Data.SqlClient;
namespace Northwind
{
class Program
{
static void Main(string[] args)
{
SqlConnection sqlConn = null;
SqlCommand sqlCmd = null;
SqlDataReader sqlDR = null;
try
{
//创建连接对象,使用集成安全方式连接,更安全
sqlConn = new SqlConnection(@"data source=localhost;
Integrated Security=SSPI;Initial Catalog=northwind");
//创建命令对象,参数1是存储过程名
string strSql = @"select categoryid, categoryname from categories;"
+ @"select employeeId, lastname from employees";
sqlCmd = new SqlCommand(strSql, sqlConn);
//打开数据库
sqlConn.Open();
//执行查询,并将结果集返回给SqlDataReader
sqlDR &#
用SqlDataReader返回多个结果集
最新推荐文章于 2019-08-11 12:50:11 发布