Click here to Skip to main content
16,017,608 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
how to make registration by user name and password and add type of user and connection to database to check data in users table.
Please i want some of help
Posted
Comments
[no name] 27-Sep-11 13:36pm    
Your question isn't quite clear. What is it you are having difficulties with, creating a registration form? Accessing the database? A login form?

1 solution

C#
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 WindowsFormsApplication_toLogIn
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnLogIn_Click(object sender, EventArgs e)
        {
            // First create DB and table, follow copy/pase connection string
            SqlConnection cnn = new SqlConnection("Your connection string");

            // For query
            SqlDataAdapter da = new SqlDataAdapter("SELECT user, pass FROM yourTable WHERE user='" + txtUser.Text + "' and pass='" + txtPass.Text + "'", cnn);

            // fill dataset
            DataSet ds = new DataSet();
            da.Fill(ds);

            // Check trust
            if (ds.Tables["yourTable"].Rows.Count > 0)
            {
                // Log in
            }
            else
            {
                // No Log in
            }
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900