Using SqlCommandBuilder show SQL statement
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
SqlConnection newConnection = new
SqlConnection(@"Data Source=R4R-3EFD13BB468\SQLEXPRESS;
initial catalog=newDatabase;integrated security=true;");
protected void Page_Load(object sender, EventArgs e)
{
newConnection.Open();
SqlDataAdapter ad = new SqlDataAdapter("select * from emp_tbl", newConnection);
SqlCommandBuilder cmd = new SqlCommandBuilder(ad);
Label1.Text = "SQL Select Command is: " + ad.SelectCommand.CommandText;
SqlCommand updateCommand = cmd.GetUpdateCommand();
Label2.Text="SQL Update Command is: " +updateCommand.CommandText;
SqlCommand insertCommand = cmd.GetInsertCommand();
Label3.Text="SQL Insert Command is: " +insertCommand.CommandText;
SqlCommand deleteCommand = cmd.GetDeleteCommand();
Label4.Text="SQL Delete Command is: " +deleteCommand.CommandText;
}
}
|
Out Put:
No comments:
Post a Comment