using System; using System.Drawing; using System.Data.Sql; using System.Data.SqlClient; public partial class teadetelisamine3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string[] pahad = { "kurat", "loll", "saabas" }; /* if (Array.IndexOf(pahad, TextBox2.Text)>=0) { Label1.Text = "tekst tsenseeritud"; return; } */ foreach (string sona in pahad) { if (TextBox2.Text.Contains(sona)) { Label1.Text = "Leiti keelatud " + sona; Label1.ForeColor = Color.Red; return; } } SqlConnection cn = new SqlConnection( @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\kursusebaas.mdf;"+ "Integrated Security=True;User Instance=True"); SqlCommand cm=new SqlCommand("INSERT INTO teated (pealkiri, jutt) "+ "VALUES (@pk, @jt)", cn); cn.Open(); cm.Parameters.AddWithValue("pk", TextBox1.Text); cm.Parameters.AddWithValue("jt", TextBox2.Text); cm.ExecuteNonQuery(); cn.Close(); } }