am creating an application that the initial page would be the registration form for first time users and the initial page changes to the login page after successful registration. Am using a access database and created a flag column. the value 1 would be hardcoded to the registation table after the registration
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.ComponentModel;
namespace DiaryApps
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new RegistrationForm());
// what am trying to do here is load the registration page once and to load the Login page for other subsequent logins
OleDbConnection newConnection;
OleDbCommand cmd = new OleDbCommand();
string Connection = @" provider=Microsoft.Jet.OLEDB.4.0; data source='Diarydatabase.mdb'; Jet OLEDB:Database Password= segunsco";
newConnection = new OleDbConnection(Connection);
newConnection.Open();
cmd.Connection = newConnection;
cmd.CommandText = "if exist(select Flag from createdDetails) begin select '1' else begin select '0' ";
OleDbDataReader MotReader = cmd.ExecuteReader();
if (MotReader.HasRows == true)
{
while (MotReader.Read())
{
string ty = MotReader.GetString(0);
if (ty == "")
{
Application.Run(new RegistrationForm());
}
if (ty == "1")
{
Application.Run(new Login());
}
newConnection.Close();
}
}
}
}
}
the problem here is that the initial page is always the login page even when my table is empty