PRACTICAL NO 6A) Multiline Textbox For Query Processing.
PRACTICAL NO 6A) Multiline Textbox For Query Processing.
WebForm.aspx.cs
using System;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2 {
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=.;
Initial Catalog=college;Integrated Security=True"); conn.Open();
SqlCommand cmd = new SqlCommand(TextBox1.Text, conn); SqlDataReader dr =
cmd.ExecuteReader(); ListBox1.Items.Clear(); while (dr.Read())
{
for (int i = 0; i <= dr.FieldCount - 1; i++)
{
ListBox1.Items.Add(dr[i].ToString());
}
}
}
}
}