🔒 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: 15
Status
Not open for further replies.

About this Thread

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

Trending Topics

Online now

Members online
496
Guests online
657
Total visitors
1,153

Forum statistics

Threads
2,279,407
Posts
28,990,539
Members
1,226,881
Latest member
puzzzyd3stroyerrr
Back
Top