Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- szotar.aspx.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.Configuration;
- using System.Data;
- using System.Data.SqlClient;
- namespace WebApplication5
- {
- public partial class Szotar : System.Web.UI.Page
- {
- SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["fordit"].ConnectionString);
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void TextBox1_TextChanged(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (DropDownList1.SelectedValue == "Angol - Magyar")
- {
- con.Open();
- SqlCommand select = new SqlCommand("SELECT Magyar, Leiras FROM fordito WHERE Angol like @forditani;", con);
- select.Parameters.AddWithValue("@forditani", TextBox1.Text);
- SqlDataReader datar;
- datar = select.ExecuteReader();
- while (datar.Read())
- {
- Label4.Text = datar[0].ToString();
- Label5.Text = datar[1].ToString();
- }
- datar.Close();
- datar.Dispose();
- }
- else if (DropDownList1.SelectedValue == "Magyar - Angol")
- {
- con.Open();
- SqlCommand select = new SqlCommand("SELECT Angol, Leiras FROM fordito WHERE Magyar like @forditani;", con);
- select.Parameters.AddWithValue("@forditani", TextBox1.Text);
- SqlDataReader datar;
- datar = select.ExecuteReader();
- while (datar.Read())
- {
- Label4.Text = datar[0].ToString();
- Label5.Text = datar[1].ToString();
- }
- datar.Close();
- datar.Dispose();
- }
- }
- catch (Exception)
- {
- Label6.Text = "Hiba!";
- }
- finally
- {
- con.Close();
- }
- }
- }
- }
- lap.aspx.cs [bevitel]
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.Configuration;
- using System.Data;
- using System.Data.SqlClient;
- namespace WebApplication5
- {
- public partial class lap : System.Web.UI.Page
- {
- SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["fordit"].ConnectionString);
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- SqlCommand insert = new SqlCommand("INSERT INTO szavak VALUES(@Angol,@Magyar,@Leiras);", con);
- insert.Parameters.AddWithValue("@Angol", TextBox1.Text);
- insert.Parameters.AddWithValue("@Magyar", TextBox2.Text);
- insert.Parameters.AddWithValue("@Leiras", TextBox3.Text);
- try
- {
- con.Open();
- if (insert.ExecuteNonQuery() < 0)
- {
- Label4.Text = "Sikertelen adatfeltoltes!";
- }
- }
- catch (Exception)
- { }
- finally
- {
- con.Close();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement