注册信息输入到MySQL中_如何将用户输入的注册信息插入的数据库中

我写的代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usi...

我写的代码如下:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.Sql;

using System.Data.SqlClient;

using System.IO;

namespace 号码管理系统

{

public partial class 新增管理员 : Form

{

public 新增管理员()

{

InitializeComponent();

}

private void send_Click(object sender, EventArgs e)

{

try

{

string Users = this.account_txt.Text;

string Pwd = this.pwd_txt.Text;

string rules = comboBox1.SelectedItem.ToString();

button1.Text = rules;

SqlConnection conn = new SqlConnection(@"Data Source=OVERSKY-PC\SQLEXPRESS;Initial Catalog=tel_mg;Integrated Security=True");

SqlCommand cmd = new SqlCommand("select 1 from log_chck where account = '" + Users + "' and pwd='" + Pwd + "'", conn);

conn.Open();

int count = Convert.ToInt32(cmd.ExecuteScalar());

if (Users == "")

{

MessageBox.Show("用户名为空");

}

else if (Pwd == "")

{

MessageBox.Show("密码为空");

}

else if (Convert.ToInt32(cmd.ExecuteScalar()) > 0)

{

MessageBox.Show("对不起!该账号已被设置,请重新设置!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

else

{

conn.Open();

string insert_sql;

insert_sql = "insert into log_chck values ('" + Users + ",'" + Pwd + "','" + rules + "')";

SqlCommand insertcmd = new SqlCommand(insert_sql, conn);

insertcmd.ExecuteNonQuery();

}

conn.Close();

}

catch

{

MessageBox.Show("对不起!操作失败!");

}

}

private void reset_Click(object sender, EventArgs e)

{

account_txt.Text = "";

pwd_txt.Text = "";

confirm_txt.Text = "";

}

}

}

数据存储用户信息的是log_chck表,字段值为account,pwd,identity。其中qccount,pwd都是来自用户填写的数据,即User,Pwd。indentity是用户在combox1中选择的数据。我不知道如何将这些数据插入数据中,具体的insert如何引用User,Pwd,combox1中的数据。

展开

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值