Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SqlConnection x = new SqlConnection(WebConfigurationManager.ConnectionStrings["fordito"].ConnectionString);
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- if (DropDownList1.Text == "Angolról")
- {
- string forditas = "SELECT Srpski,Opis FROM Szavak WHERE Engleski = @szavak";
- SqlCommand forditasstring = new SqlCommand(forditas, x);
- forditasstring.Parameters.AddWithValue("@szavak", TextBox1.Text);
- try
- {
- x.Open();
- SqlDataReader dr = forditasstring.ExecuteReader();
- while (dr.Read())
- {
- TextBox2.Text = dr[0].ToString();
- TextBox3.Text = dr[1].ToString();
- }
- dr.Close();
- }
- catch (Exception hiba)
- {
- Label4.Text = hiba.ToString();
- }
- finally
- {
- x.Close();
- }
- }
- else if (DropDownList1.Text == "Szerbről")
- {
- string forditas = "SELECT Engleski,Opis FROM Szavak WHERE Srpski = @szavak";
- SqlCommand forditasstring = new SqlCommand(forditas, x);
- forditasstring.Parameters.AddWithValue("@szavak", TextBox1.Text);
- try
- {
- x.Open();
- SqlDataReader dr = forditasstring.ExecuteReader();
- while (dr.Read())
- {
- TextBox2.Text = dr[0].ToString();
- TextBox3.Text = dr[1].ToString();
- }
- dr.Close();
- }
- catch (Exception hiba)
- {
- Label4.Text = hiba.ToString();
- }
- finally
- {
- x.Close();
- }
- }
- SqlConnection x = new SqlConnection(WebConfigurationManager.ConnectionStrings["fordito"].ConnectionString);
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- string insert = "INSERT INTO Szavak VALUES(@engleski,@srpski,@opis)";
- SqlCommand insertstring = new SqlCommand(insert, x);
- insertstring.Parameters.AddWithValue("@srpski", TextBox1.Text);
- insertstring.Parameters.AddWithValue("@engleski", TextBox2.Text);
- insertstring.Parameters.AddWithValue("@opis", TextBox3.Text);
- x.Open();
- if (insertstring.ExecuteNonQuery() > 0)
- {
- Label4.Text = "Sikerült";
- }
- else
- {
- Label4.Text = "Nem sikerült";
- }
- }
- catch (Exception c)
- {
- Label4.Text = c.ToString();
- }
- finally
- {
- x.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement