J
Jase Asmussen
Guest
So I got a login application and when you click login when you have nothing filled in it should give you an error but if I click it once it goes and says its correct and I <g class="gr_ gr_82 gr-alert gr_spell gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="82" id="82">cliked</g> the login button again and this <g class="gr_ gr_106 gr-alert gr_gramm gr_run_anim Punctuation multiReplace" data-gr-id="106" id="106"><g class="gr_ gr_101 gr-alert gr_spell gr_disable_anim_appear ContextualSpelling ins-del multiReplace" data-gr-id="101" id="101">happend</g>..</g>
An unhandled exception of type System.InvalidOperationException occurred in System.Data.dll
Additional information: The ConnectionString property has not been initialized.
Heres all my code
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;
using System.Data.OleDb;
namespace Viper_Safe
{
public partial class <g class="gr_ gr_157 gr-alert gr_gramm gr_run_anim Style multiReplace" data-gr-id="157" id="157">login :</g> Form
{
private OleDbConnection connection = new OleDbConnection();
public login()
{
InitializeComponent();
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Users\SillyTen9\Documents\UserDatabase.accdb; Persist Security Info=False;";
}
private void bunifuFlatButton2_Click(object sender, EventArgs e)
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "select * from UserDatabase where Email=" + bunifuMetroTextbox1.Text + " and Password=" + bunifuMetroTextbox2.Text + "";
OleDbDataReader reader = command.ExecuteReader();
int count = 0;
while (reader.Read())
{
count = count + 1;
}
if (count == 1)
{
MessageBox.Show("Username and passwrd is correct!");
connection.Close();
connection.Dispose();
// this.Hide();
// FORM f4 = new FORM();
// f4.ShowDialog();
}
if (count > 1)
{
MessageBox.Show("Duplicate Username and password");
}
if (count == 0)
{
MessageBox.Show("Username and password is not correct");
}
connection.Close();
}
private void bunifuImageButton2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void login_Load(object sender, EventArgs e)
{
try
{
connection.Open();
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Unable to connect?", "Error" + ex);
}
}
private void bunifuCustomLabel4_Click(object sender, EventArgs e)
{
this.Hide();
sign_up sf = new sign_up();
sf.ShowDialog();
}
}
}
Continue reading...
An unhandled exception of type System.InvalidOperationException occurred in System.Data.dll
Additional information: The ConnectionString property has not been initialized.
Heres all my code
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;
using System.Data.OleDb;
namespace Viper_Safe
{
public partial class <g class="gr_ gr_157 gr-alert gr_gramm gr_run_anim Style multiReplace" data-gr-id="157" id="157">login :</g> Form
{
private OleDbConnection connection = new OleDbConnection();
public login()
{
InitializeComponent();
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Users\SillyTen9\Documents\UserDatabase.accdb; Persist Security Info=False;";
}
private void bunifuFlatButton2_Click(object sender, EventArgs e)
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "select * from UserDatabase where Email=" + bunifuMetroTextbox1.Text + " and Password=" + bunifuMetroTextbox2.Text + "";
OleDbDataReader reader = command.ExecuteReader();
int count = 0;
while (reader.Read())
{
count = count + 1;
}
if (count == 1)
{
MessageBox.Show("Username and passwrd is correct!");
connection.Close();
connection.Dispose();
// this.Hide();
// FORM f4 = new FORM();
// f4.ShowDialog();
}
if (count > 1)
{
MessageBox.Show("Duplicate Username and password");
}
if (count == 0)
{
MessageBox.Show("Username and password is not correct");
}
connection.Close();
}
private void bunifuImageButton2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void login_Load(object sender, EventArgs e)
{
try
{
connection.Open();
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Unable to connect?", "Error" + ex);
}
}
private void bunifuCustomLabel4_Click(object sender, EventArgs e)
{
this.Hide();
sign_up sf = new sign_up();
sf.ShowDialog();
}
}
}
Continue reading...