Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace WindowsFormsApplication1
- {
- public partial class AuthorizationForm : Form
- {
- public AuthorizationForm()
- {
- InitializeComponent();
- }
- private void Button1_Click(object sender,EventArgs e)
- {
- this.Close();
- }
- ////////////////////////////////
- private void insertData()
- {
- string conStr = "server=localhost;user=root;database=exam1;password=qwerty;";
- using (SqlConnection con = new SqlConnection(conStr))
- {
- try
- {
- string sql = "INSERT INTO Login (user,password) VALUES (@user, @password);";
- con.Open();
- SqlCommand cmd = new SqlCommand(sql, con);
- cmd.Parameters.AddWithValue("@user",textBox1.Text);
- cmd.Parameters.AddWithValue("@password",textBox2.Text);
- cmd.ExecuteNonQuery();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- ////////////////////////////////////////
- private void Button2_Click(object sender,EventArgs e)
- {
- insertData();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement