Hello, I'm sorry for posting a question that is most probably very easy for most programmers. I am trying to learn C# and as much as I've googled trying to find the answer, I could not find anything that I understand.
I am aware that there is a login authentication thread in this site for C#. However I am doing the project on a WINDOWS FORM APPLICATION and not a website. And most tutorials I've encountered performs tthe code in ASP.net. Please help me understand. I am using Visual Studio 2008 Express Edition and MS SQL Server 2005.
In so far as I have coded, this is what I have
Code:
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.OleDb;
namespace WindowsFormsApplication2
{
public partial class LOGIN : Form
{
public LOGIN()
{
InitializeComponent();
}
private void Cancel_Btn_Click(object sender, EventArgs e)
{
Close();
}
private void Login_Btn_Click(object sender, EventArgs e)
{
/*####################### VALIDATION #########################*/
if ((username_input.Text == "") && (Password_input.Text == ""))
{
ErrorLogin_Lbl.Text = "Please enter your initials and password";
}
else if (username_input.Text == "")
{
ErrorLogin_Lbl.Text = "Please enter your initials";
}
else if (Password_input.Text == "")
{
ErrorLogin_Lbl.Text = "Please enter your password";
}
else
{
ErrorLogin_Lbl.Text = "";
/*################## CHECKING IF IN DATABASE ##################*/
string sConnection = "Provider=SQLOLEDB;Data Source=RITZEL-PC@SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=NNIT-RMS";
OleDbConnection dbConn = new OleDbConnection(sConnection); //database connection
dbConn.Open(); //open connection
//retrieve data from database
string UsersDB = "SELECT UserID, Initials, Password FROM dbo.Users";
OleDbCommand dbCommand = new OleDbCommand;
dbCommand.CommandText = UsersDB;
dbCommand.Connection = dbConn;
OleDbDataReader dbReader = dbCommand.ExecuteReader();
}
}
}
}