🔒 Closed c# visual studio 2015 using sql server

Status
Not open for further replies.

moimoi018

Leecher
Capture.webp
boss pa help naman sa visual studio 2015 na stuck ako sa login form. wala po akong makita na error pero po nag iinvalid yung login ko
Login form
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MiniPayroll
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            Connection con = new Connection();
            con.dataGet("Select * from [User] Where UserName = '"+txtUserName.Text +"' and Password = ' " + txtPassword.Text + " ' ");
            DataTable dt = new DataTable();
            con.sda.Fill(dt);
            if (dt.Rows.Count > 0)
            {

                this.Hide();
                frmMain frm = new frmMain();
                frm.Show();

            }
            else
            {
                MessageBox.Show("Invalid Username & Password..!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}

tas gumamit po ako ng class para sa sql server ko pa help naman po.. tnk u

C#:
using System;
using System.Data.SqlClient;

namespace MiniPayroll
{
    class Connection
    {
        public SqlConnection con;
        public SqlCommand cmd;
        public SqlDataAdapter sda;
        public string pkk;

        public void connection()
        {
            con = new SqlConnection(@"Data Source=OPPO; Initial Catalog=MiniPayroll;Integrated Security=True");
            con.Open();
        }
        public void dataSend(string SQL)
        {
            try
            {
                connection();
                cmd = new SqlCommand(SQL, con);
                cmd.ExecuteNonQuery();

                pkk = "";
            }
            catch (Exception)
            {
                pkk = "Please Check Your Data";
            }
            con.Close();
        }
        public void dataGet(string SQL)
        {
            try
            {
                connection();
                sda = new SqlDataAdapter(SQL, con);
            }
            catch (Exception)
            {

            }
        }

    }
}
 

Attachments

  • Capture.webp
    Capture.webp
    28.1 KB · Views: 17
Status
Not open for further replies.

About this Thread

  • 0
    Replies
  • 909
    Views
  • 1
    Participants
Last reply from:
moimoi018

Trending Topics

Online now

Members online
1,054
Guests online
7,021
Total visitors
8,075

Forum statistics

Threads
2,354,212
Posts
29,382,706
Members
1,079,373
Latest member
juanega05
Back
Top