using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlServerCe; namespace khtwa { public partial class Form1 : Form { public Form1() { InitializeComponent(); } string msg; SqlCeCommand cmd; DataSet ds = new DataSet(); private void textBox1_TextChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text=""; this.Close(); } private void button2_Click(object sender, EventArgs e) { string y = (Application.StartupPath + "\\font.sdf"); SqlCeConnection con = new SqlCeConnection(@"Data Source=" + y); con.Open(); if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show(" Enter UserName and Password ."); return; } cmd = new SqlCeCommand("SELECT * FROM login where user='" + textBox1.Text + "' and password='" + textBox2.Text + "'", con); SqlCeDataAdapter da = new SqlCeDataAdapter(cmd); da.Fill(ds); int i = ds.Tables[0].Rows.Count; if (i == 1) { msg = "Welcome " + textBox1.Text; this.Hide(); Form2 f2 = new Form2(); f2.Show(); ds.Clear(); } else { MessageBox.Show("Not Registered User or Invalid Name/Password"); textBox2.Text = ""; } } } }
logins
login
SELECT * FROM login where user= 'xxx' and password = 'yyyy'
@user
@password
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)