TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Michael Taylor
NA
4
510
Making a Login Form Connected to a DB
May 21 2019 10:45 AM
I've been trying to teach myself how to do this for a few days now but can't figure out certain things.
This is what I have currently and I can't, for the life of me, figure out where I'm wrong at. I hope this isn't a lost cause as I'm trying to help my school get out of using paper for certain things and this is my first step.
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
using
System.Data.Sql;
using
System.Data.SqlClient;
namespace
CCCLogin
{
public
partial
class
Form2 : Form
{
public
Form2()
{
InitializeComponent();
}
private
void
Exit_Click(
object
sender, EventArgs e)
{
this
.Close();
}
private
void
Login_Click(
object
sender, EventArgs e)
{
SqlConnection con =
new
SqlConnection(@
"Data Source=(LOCALDB)\MSSQLLocalDB.C:\USERS\MICHAELC0837\DOCUMENTS\CCCLOGIN\CCCEMPLOYEES.mdf; Initial Catalog=CCCEMPLOYEES.mdf; Integrated Security=True"
);
SqlDataAdapter sda =
new
SqlDataAdapter(
"select count(*) from Username where username='"
+ UserTxtBox +
"and password='"
+ PassTxtBox +
"'"
, con);
DataTable dt =
new
DataTable();
sda.Fill(dt);
if
(dt.Rows[0][0]).ToString() ==
"1"
)
{
this
.Hide();
CCCLogin ss =
new
CCCLogin();
ss.Show();
}
else
MessageBox.Show(
"please enter correct username and password"
,
"alert"
, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
Reply
Answers (
3
)
making calculations w user input and displaying the results
Installer creating using Visual Studio 2015