User221424154 posted
I'm using visual studio 2015. I want to get the result set in sqldatareader. Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class ADO2 : System.Web.UI.Page
{
SqlConnection cn = null;
SqlCommand cmd = null;
SqlDataAdapter dr = null;
string sqlCommandText = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
cn = new SqlConnection("Data Source=DELL;Database=ASPDB;User Id=sa;Password=123");
}
protected void button1_Click(object sender, EventArgs e)
{
sqlCommandText = "Select * from Dept,Select * from Emp";
if (cn.State != ConnectionState.Open)
cn.Open();
cmd = new SqlCommand(sqlCommandText, cn);
dr = cmd.ExecuteReader();
}
}