早教吧 育儿知识 作业答案 考试题库 百科 知识分享

英语翻译usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;namespaceWindowsFormsApplication2

题目详情
英语翻译
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication24
{
public partial class Form2 :Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender,EventArgs e)
{
}
private void button1_Click(object sender,EventArgs e)
{
this.Close();
}
private void button2_Click(object sender,EventArgs e)
{
SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;
AttachDBFilename=|DataDirectory|Database1.mdf;Integrated Security=True;User Instance=True");
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "insert into Table1(Name,Password) values(@name,@pwd)";
cmd.CommandText = "select*from Table1 where Name=@aa";
cmd.Parameters.AddWithValue("aa",textBox1.Text);
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
return;
}
if (textBox1.Text == "")
{
MessageBox.Show( "请输入用户名");
return;
}
if (textBox2.Text == "")
{
MessageBox.Show("请输入密码");
return;
}
cmd.Dispose();
conn.Dispose();
SqlConnection conn1 = new SqlConnection(@"Data Source=.\SQLEXPRESS;
AttachDBFilename=|DataDirectory|Database1.mdf;Integrated Security=True;User Instance=True");
conn1.Open();
SqlCommand cmd1 = conn1.CreateCommand();
cmd1.CommandText = "insert into Table1(Name,Password) values(@name,@pwd)";
cmd1.Parameters.AddWithValue("name",textBox1.Text);
cmd1.Parameters.AddWithValue("pwd",textBox2.Text);
cmd1.ExecuteNonQuery();
MessageBox.Show("注册成功!");
textBox1.Text = "";
textBox2.Text = "";
cmd.Dispose();
conn1.Dispose();
}
private void textBox2_TextChanged(object sender,EventArgs e)
{
}
private void textBox1_TextChanged(object sender,EventArgs e)
{
}
}
}
▼优质解答
答案和解析
就是个连接数据库的登陆/注册的窗体,这些你随便在网上一搜就一堆