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
Enzo Enzo
NA
26
2.8k
An unhandled exception of type 'System.Data.SqlClient.SqlExc
Jan 17 2017 12:20 PM
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.SqlClient;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection("server = localhost; user id = root; password=admin1234; database = test");
cn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM users where username = '" + txtusername.Text + "', and passw =' " + txtpassword.Text + "'", cn);
SqlDataReader dr;
dr = cmd.ExecuteReader();
int count = 0;
while (dr.Read())
{
count += 1;
}
if (count == 1)
{
MessageBox.Show("OK");
Form2 f2 = new Form2();
f2.Show();
}
else if (count > 0)
{
MessageBox.Show("Duplicate username and password");
}
{
MessageBox.Show("username or password note correct");
}
txtusername.Clear();
txtpassword.Clear();
}
}
}
Reply
Answers (
9
)
Use Control Monthcalendar
login form mysql problem