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
Chidiebere Mgbemena
NA
179
14.2k
Having problem connecting to database
Mar 18 2020 8:52 AM
Please i need help!!!
What can i do?
my login form is giving error when i try to login after running the application. Below is the
error message:
My source code:
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 Sales_Invoice
{
public partial class frmLogin : Form
{
private object txtUserName;
private object txtPassword;
public frmLogin()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=ABJ-DEVSVR-01\MINTSQL;Initial Catalog=Contacts;Integrated Security=True");
SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) From Login where Username='" + txtUserName + "' and Password='" + txtPassword + "'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
Main ss = new Main();
ss.Show();
}
else
{
MessageBox.Show("Please check your Username and Password");
}
}
private void frmLogin_Load(object sender, EventArgs e)
{
}
}
}
Reply
Answers (
7
)
How to select data from RequestesEmail table based on two co
why this query is very slow when add these 4 lines ?