值不会进入数据库我添加信息但不更新数据库服务器。
namespace InsertDatabase00
{
public partial class Form1 : Form
{
SqlCommand cmd = new SqlCommand();
SqlConnection con;
SqlDataAdapter da;
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
con = new SqlConnection(@"Data Source=PHOENIX\SQLEXPRESS1;Initial Catalog=Itzoz;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=True");
con.Open();
cmd = new SqlCommand("Insert Into EmpData(Name,Email,Gender) values (@Name,@Email,@Gender)", con);
cmd.Parameters.Add("@Name", textBox1.Text);
cmd.Parameters.Add("@Email", textBox2.Text);
cmd.Parameters.Add("@Gender", comboBox1.SelectedItem.ToString());
cmd.ExecuteNonQuery();
}
}
}