为了账号安全,请及时绑定邮箱和手机立即绑定

如何:将结果添加到与登录相同的数据库

如何:将结果添加到与登录相同的数据库

C#
翻翻过去那场雪 2022-11-21 21:28:45
我的应用程序显示了一家餐厅的菜单,在使用数据库中的电子邮件和密码登录后,客户端会引导您使用一台计算机,该计算机会在特定日期后计算卡路里。我希望能够将结果放在同一个数据库和客户端用作图像的相同数据中。这是我参加比赛的申请private void button1_Click(object sender, EventArgs e){    ani = Convert.ToInt32(textBox1.Text);    cm = Convert.ToInt32(textBox2.Text);    kg = Convert.ToInt32(textBox3.Text);    s = ani + cm + kg;    if (s < 250) label_mesaj.Text = "1800";    else if (s >= 250 && s <= 275) label_mesaj.Text = "2200";    else label_mesaj.Text = "2500";}private void button2_Click(object sender, EventArgs e){    SqlConnection con = new SqlConnection(constr);    con.Open();    SqlCommand cmd = new SqlCommand("insert into Clienti(parola,nume,prenume,adresa,email)values('" + textBox4.Text + "','" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox6.Text + "')", con);    SqlDataAdapter da = new SqlDataAdapter(cmd);    DataSet ds = new DataSet();    da.Fill(ds);}这是在注册后向我的数据库添加新客户的代码,所以我不知道如何记住“id_clienti”我希望“label_mesaj”在使用相同数据登录后显示在数据库中的“kcal_zilnice”上。
查看完整描述

1 回答

?
jeck猫

TA贡献1909条经验 获得超7个赞

这就是我设法解决问题的方法我记得电子邮件的登录部分


private void button1_Click(object sender, EventArgs e)

    {

        SqlConnection con = new SqlConnection(constr);

        SqlDataAdapter da = new SqlDataAdapter("Select count(*) from Clienti where email='" + textBox1.Text + "' and Parola='" + textBox2.Text + "'", con);

        DataTable dt = new DataTable();

        da.Fill(dt);

        if (dt.Rows[0][0].ToString() == "1")

        {

            client.email = textBox1.Text;

            this.Hide();

            Form4 ssss = new Form4();

            ssss.Show();

        }

        else MessageBox.Show("verifica datele");

    }

在下一个表格中


private void button1_Click(object sender, EventArgs e)

    {

        SqlConnection con = new SqlConnection(constr);

        SqlDataAdapter da = new SqlDataAdapter();

        con.Open();if (s < 250)  label_mesaj.Text = "1800";

        da.UpdateCommand = new SqlCommand("Update Clienti set kcal_zilnice= '" + label_mesaj.Text + "' where email= '" + Form3.client.email.ToString() + "'", con);

        da.UpdateCommand.ExecuteNonQuery();

        da.UpdateCommand.Dispose();

        con.Close();

    }


查看完整回答
反对 回复 2022-11-21
  • 1 回答
  • 0 关注
  • 141 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号