Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 1.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data.OleDb;
  8.  
  9. public partial class Pages_newuser : System.Web.UI.Page
  10. {
  11.     protected void Page_Load(object sender, EventArgs e)
  12.     {
  13.  
  14.     }
  15.  
  16.     protected void Button_ajouter_Click(object sender, EventArgs e)
  17.     {
  18.         string sql = "select * from ids where user='" + TextBox_user.Text + "'";
  19.         string sql2 = "insert into ids values('" + TextBox_user.Text + "','" + TextBox_password.Text + "')";
  20.         OleDbConnection con = new OleDbConnection();
  21.         OleDbCommand cmd = new OleDbCommand();
  22.         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";
  23.         cmd.Connection = con;
  24.         try
  25.         {
  26.             con.Open();
  27.             cmd.CommandText = sql;
  28.             cmd.ExecuteNonQuery();
  29.             OleDbDataReader reader = cmd.ExecuteReader();
  30.             int count = 0;
  31.             while (reader.Read())
  32.             {
  33.                 count++;
  34.             }
  35.             if (count == 1)
  36.             {
  37.                 Label.Text = "nom d'utilisateur dija existe essaie un autre ";
  38.                 con.Close();
  39.             }
  40.             if (count < 1)
  41.             {
  42.                     con.Open();
  43.                     cmd.CommandText = sql2;
  44.                     cmd.ExecuteNonQuery();
  45.                     Label.Text = "le compte d'utilisateur est ajouté ";
  46.                     con.Close();
  47.             }
  48.  
  49.            
  50.         }
  51.         catch (Exception)
  52.         {
  53.             con.Close();
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement