C# 如何从sql数据库在wpf窗口中显示特定的用户数据?

C# 如何从sql数据库在wpf窗口中显示特定的用户数据?,c#,sql,wpf,C#,Sql,Wpf,我正在做一个简单的wpf项目。有三种表格,第一种是登录表格,第二种是注册表格,第三种是个人资料表格。项目要求是,当我在注册页面注册任何用户时,它会将我重定向到配置文件表单,并向我显示刚刚创建的用户的完整配置文件 private void btnSubmit_Click(object sender, RoutedEventArgs e) { SqlDataAdapter da = new SqlDataAdapter(); str

我正在做一个简单的wpf项目。有三种表格,第一种是登录表格,第二种是注册表格,第三种是个人资料表格。项目要求是,当我在注册页面注册任何用户时,它会将我重定向到配置文件表单,并向我显示刚刚创建的用户的完整配置文件

  private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            SqlDataAdapter da = new SqlDataAdapter();
            string cs = ConfigurationManager.ConnectionStrings["CS"].ConnectionString;

            if (txtUsername.Text  ==  ""  ||
                txtPasswd.Text    ==  ""  ||
                txtName.Text      ==  ""  ||
                txtEmail.Text     ==  ""  ||
                txtMobile.Text    ==  "" 
               )
            {
                MessageBox.Show("Please fill the empty fields", "Warning");
            }
            else
            {
                using (SqlConnection con = new SqlConnection(cs))
                {
                    string queryString = "Insert Into tblLogin Values(@Username,@Password,@Name,@Email,@Mobile)";

                    if (!Regex.IsMatch(txtEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
                    {
                        MessageBox.Show("Please enter a valid email", "Error");
                    }
                    else
                    {
                        da.InsertCommand = new SqlCommand(queryString, con);
                        da.InsertCommand.Parameters.Add("@Username", SqlDbType.NVarChar, 100).Value = txtUsername.Text;
                        da.InsertCommand.Parameters.Add("@Password", SqlDbType.NVarChar, 100).Value = txtPasswd.Text;
                        da.InsertCommand.Parameters.Add("@Name", SqlDbType.VarChar, 100).Value = txtName.Text;
                        da.InsertCommand.Parameters.Add("@Email", SqlDbType.NVarChar, 100).Value = txtEmail.Text;
                        da.InsertCommand.Parameters.Add("@Mobile", SqlDbType.NVarChar, 100).Value = txtMobile.Text;

                        con.Open();
                        da.InsertCommand.ExecuteNonQuery();

                        MessageBox.Show("Registration completed");
                    }

                }

完成注册后,我想在另一个页面上显示刚刚创建的用户配置文件。有人可以帮助我如何执行此操作。任何帮助都将非常有用。

您需要阅读官方文档。如果你阅读并尝试使用,那将是有趣的

希望能有帮助