Пример #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            nickBox.Text = data;
            SqlConnection conn = DBUtils.GetDBConnection();

            try
            {
                conn.Open();
                string        emailCommand    = ("select [email] from [dbo].[User] where [name] ='" + nickBox.Text + "';");
                SqlCommand    sqlEmailCommand = new SqlCommand(emailCommand, conn);
                SqlDataReader rdEmail;
                rdEmail = sqlEmailCommand.ExecuteReader();
                while (rdEmail.Read())
                {
                    emailBox.Text = rdEmail["email"].ToString();
                }
                rdEmail.Close();
                string        regDateCommand = ("select [regdate] from [dbo].[User] where [name] ='" + nickBox.Text + "';");
                SqlCommand    sqlCommand     = new SqlCommand(regDateCommand, conn);
                SqlDataReader rdRegDate;
                rdRegDate = sqlCommand.ExecuteReader();
                while (rdRegDate.Read())
                {
                    regDateBox.Text = DateTime.Parse(rdRegDate["regdate"].ToString()).ToShortDateString();
                }
                rdRegDate.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            finally
            {
                conn.Close();
            }
        }