Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data.OleDb;
- public partial class Pages_newuser : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button_ajouter_Click(object sender, EventArgs e)
- {
- string sql = "select * from ids where user='" + TextBox_user.Text + "'";
- string sql2 = "insert into ids values('" + TextBox_user.Text + "','" + TextBox_password.Text + "')";
- OleDbConnection con = new OleDbConnection();
- OleDbCommand cmd = new OleDbCommand();
- con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\client\Documents\Visual Studio 2015\WebSites\gestion de stock\App_Data\Gestion de stock.accdb";
- cmd.Connection = con;
- try
- {
- con.Open();
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- OleDbDataReader reader = cmd.ExecuteReader();
- int count = 0;
- while (reader.Read())
- {
- count++;
- }
- if (count == 1)
- {
- Label.Text = "nom d'utilisateur dija existe essaie un autre ";
- con.Close();
- }
- if (count < 1)
- {
- con.Open();
- cmd.CommandText = sql2;
- cmd.ExecuteNonQuery();
- Label.Text = "le compte d'utilisateur est ajouté ";
- con.Close();
- }
- }
- catch (Exception)
- {
- con.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement