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;
namespace iss_farmacie_spitali
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
sqlConnection1.Open();
sqlCommand1.Parameters.AddWithValue("user",textBox1.Text);
sqlCommand1.Parameters.AddWithValue("pass",textBox2.Text);
sqlCommand1.CommandText = "SELECT id,parola FROM ANGAJAT WHERE id=(user) AND parola=(pass)";
if (sqlCommand1.ExecuteNonQuery()!=null)
MessageBox.Show("ESTE");
sqlConnection1.Close();
}
}
}
What I hope to accomplish is build a functional login. I have the database, a table named "angajati"(employees) containing id(a username practically) and parola(which is password). What I want to know it I can introduce "variables" within the SQL script text to have it run like a function and simply pass the values from my text boxes. This is what I made up from other examples but it doesn't seem to work. Could anybody give me a bit of insight upon the matter?