I have to create a lottery program with c#.
Tables who I use is 3.
First table :Clients
Client_num Client_Name Client_ID
Second table: Prize
Prize_Name Prize_ID
3rd Table: Report
Prize_ID Client_ID ID_Number --(who can be not unique).
My task is to create a form who visualize client num (between 1 to 435333, every months client num is differt, because i generated them from specific criteria).
For that I use select query in my code - who return the MAX ID from table Clents
.
Except client num i have to visualize name of prize and this two rows have to visualize in report. My question is - How to create Random number between 1 to 435533 as these number to be a client num from "client" table in textbox - Client number.
Here is the code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Random Lottery = new Random();
SqlConnection con = new SqlConnection("Data Source=sqlsrvr;Initial Catalog=lottery;Integrated Security=True;");
con.Open();
SqlCommand cmd = new SqlCommand("SELECT MAX(id) AS ID FROM clients", con);
cmd.ExecuteNonQuery();
con.Close();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
}
}
Aucun commentaire:
Enregistrer un commentaire