(I am using my local host and mysql, and oledb for connecting to the database. )
I get the error the name 'user' and 'password' does not exist in the current context? Im trying to validate the input gathered from the textbox1 and textbox2 against the sql query of the database but at current it just ignores the sql command and opens up the form no matter what input i put in...
I have been trying to figure this out for almost two weeks and have looked all over the internet to find a login connection using oledb but have only been able to find 'mysqlconnection' ?
Any help would be greatly appreciated
My code is below
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.OleDb;
namespace Name of Namespace
{
public partial class Form1 : Form
{
public static string ConnectionString = "Provider=MySQLProv;Data Source=DATABASE NAME;User Id=root;Password=password;";
public Form1()
{
InitializeComponent();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection myConnection = new OleDbConnection(ConnectionString);
string uname;
string pword;
try
{
uname = textBox1.Text;
pword = textBox2.Text;
{
OleDbCommand myCommand = new OleDbCommand("Select * from user where username = ' " + textBox1.Text + " 'and password=' " + textBox2.Text + " ' ");
if (user = uname && password = pword)
{
main_screen main = new main_screen();
main.Show();
}
else
{
Application.Exit();
}
}
}
catch (Exception ex)
{
myConnection.Close();
MessageBox.Show("Wrong Input Entered", "Window Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}

New Topic/Question
Reply




MultiQuote






|