Database tables: Registration & Purchase (Using Unique ID ranged 1-10000 as primary key and foreign key connecting to two tables)
How can I put on unique ID to my Purchase tables when tourists with corresponding ID do the online purchase?
I am using visual studio to work out the asp.net. However, how can I store the clients Unique ID to identify their logging activities?
string result = "0";
OleDbConnection connection = new OleDbConnection();
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\sim\Desktop\Web.accdb";
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "select ID from Registration where Name ='" + TextBox1.Text + "' and Password ='" + TextBox2.Text + "'";
string getValue = command.ExecuteScalar().ToString();
if (getValue != null)
{
result = getValue.ToString();
}
Session.Add("UserID", result);
command.CommandText = "select * from Registration where Name ='" + TextBox1.Text + "' and Password ='" + TextBox2.Text + "'";
OleDbDataReader reader = command.ExecuteReader();
int count = 0;
while (reader.Read())
{
count = count + 1;
}
if (String.IsNullOrEmpty(TextBox1.Text))
{
MessageBox.Show("You have't input the Username.");
}
if (String.IsNullOrEmpty(TextBox2.Text))
{
MessageBox.Show("you havn't input the Password.");
}
if (count == 1)
{
MessageBox.Show("Username and password is valid");
connection.Close();
connection.Dispose();
Response.Redirect("Loginpage.aspx", true);
}
else
{
MessageBox.Show("Username or Password is not matched");
}
}