编程环境:
- Windows 10
- Visual Studio 2019
- SQLserver
界面
利用Button、Lable、TextBox控件处理界面,注意摆放位置的整洁美观。
双击Button OK:
把老师给的代码粘贴进去
private void button1_Click(object sender, EventArgs e)
{
string username = textBoxUserName.Text.Trim(); //取出账号
string password = textBoxPassWord.Text.Trim(); //取出密码
//string connstr = ConfigurationManager.ConnectionStrings["connectionString"].ToString(); //读取连接字符串
string myConnString = "Data Source=.;Initial Catalog=Text;Persist Security Info=True;User ID=sa;Password=110023"; //连接字符串 Data source为服务器的名字 Text为连接的库
SqlConnection sqlConnection = new SqlConnection(myConnString); //实例化连接对象
sqlConnection