-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sql3.aspx.cs
58 lines (53 loc) · 1.94 KB
/
Sql3.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Windows.Forms;
namespace Birger_Bolcher
{
public partial class Sql3 : System.Web.UI.Page
{
string Conn = @"Data Source=DESKTOP-5OTVSE3\SQLEXPRESS;Initial Catalog=Bolcher;Integrated Security=True";
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString))
{
if(cn.State == ConnectionState.Closed)
{
cn.Open();
using (SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM BOLCHER", cn))
{
da.Fill(dt);
GridView1.DataSource = dt;
}
}
}
}
DataTable dt = new DataTable("Bolcher");
protected void Button1_Click(object sender, EventArgs e)
{
using (SqlConnection sqlCon = new SqlConnection(Conn))
{
sqlCon.Open();
SqlCommand command = new SqlCommand("SELECT * FROM Bolcher", sqlCon);
SqlDataAdapter SqlDa = new SqlDataAdapter(command);
DataSet ds = new DataSet();
SqlDa.Fill(ds);
};
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
DataView dv = dt.DefaultView;
dv.RowFilter = string.Format("Navn LIKE '%{0}%'", TextBox1.Text);
GridView1.DataSource = dv.ToTable();
}
}
}
}