add this value and key in web.config
some sql statements:
sp_helpdb
SELECT * FROM sysobjects and sp_help
Html Coding for this:
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
SqlCommand cmd;
SqlDataAdapter da;
DataSet ds=new DataSet();
SqlConnection cnn;
SqlDataReader dr;
String strDB;
protected void Page_Load(object sender, EventArgs e)
{
cnn = new SqlConnection(ConfigurationManager.AppSettings.Get("Cnn"));
cnn.Open();
da = new SqlDataAdapter("sp_helpdb", cnn);
da.Fill(ds, "Cat");
if (!IsPostBack)
{
ddlDb.DataSource = ds.Tables["Cat"];
ddlDb.DataTextField = "name";
DataBind();
}
}
protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{
}
protected void ddlDb_SelectedIndexChanged(object sender, EventArgs e)
{
strDB = ddlDb.SelectedItem.ToString();
cnn = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog='"+strDB+"';Integrated Security=True");
da = new SqlDataAdapter("SELECT * FROM sysobjects WHERE xtype = 'u'", cnn);
da.Fill(ds, "student");
ddlTable.DataSource = ds.Tables["student"];
ddlTable.DataTextField = "name";
DataBind();
}
protected void ddlTable_SelectedIndexChanged(object sender, EventArgs e)
{
strDB = ddlDb.SelectedItem.ToString();
cnn = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog='" + strDB + "';Integrated Security=True");
cnn.Open();
cmd = new SqlCommand("sp_help " + ddlTable.SelectedItem.ToString(), cnn);
dr = cmd.ExecuteReader();
dr.NextResult();
while (dr.Read())
lstFields.Items.Add(dr["column_name"].ToString());
}
protected void btnExecute_Click(object sender, EventArgs e)
{
strDB = ddlDb.SelectedItem.ToString();
cnn = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog='" + strDB + "';Integrated Security=True");
cnn.Open();
{
SqlCommand smd = new SqlCommand(TextBox1.Text, cnn);
dr = smd.ExecuteReader();
{
DataTable dt = new DataTable();
dt.Load(dr);
DataGrid1.DataSource = dt;
DataGrid1.DataBind();
}
}
}
}
ASP.NET is a development framework for building web pages and web sites with HTML, CSS, JavaScript and server scripting. ASP.NET supports three different development models: Web Pages, MVC (Model View Controller), and Web Forms.
Subscribe to:
Post Comments (Atom)
Using Authorization with Swagger in ASP.NET Core
Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models { ...
-
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.D...
-
<ControlTemplate x:Key="TextBoxBaseControlTemplate" TargetType="{x:Type TextBoxBase}"> <Borde...
-
<?xml version="1.0" encoding="utf-8"?> <Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting...
No comments:
Post a Comment