跟着视频来的,不知道代码哪里出错了,求解。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Transport
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string id = textBox1.Text;
string pwd = textBox2.Text;
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Server=.;uid=sa;pwd=112233;database=T_uird";
conn.Open();
SqlCommand cmd =new SqlCommand("server *from name='"+id+"'"+"and password='"+pwd+"'",conn);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.HasRows)
{
MessageBox.Show("登录成功!");
Form2 f2 = new Form2();
f2.ShowDialog();
}
else
{
MessageBox.Show("账号或密码输入错误,请重新输入!");
}
sdr.Close();
conn.Close();
}
}
}