VS2019,写出的程序在查询窗口的Open可用,在写增加的窗口功能时不可用了
但是在search的时候可用
后面附代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WinFormsApp1
{
public partial class tic_add : Form
{
tic_search ss = new tic_search();
public tic_add()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string strsql = "insert into tic(tno,cno,rnum,seat,way)";
strsql += "values(@tno,@cno,@rnum,@seat,@way)";
SqlParameter sp_tno = new SqlParameter("@tno",tno_add.Text);
SqlParameter sp_cno = new SqlParameter("@cno", cno_add.Text);
SqlParameter sp_rnum = new SqlParameter("@rnum", rnum_add.Text);
SqlParameter sp_seat = new SqlParameter("@seat", seat_add.Text);
SqlParameter sp_way = new SqlParameter("@way", way_add.Text);
/*string strsex="女"
* SqlParameter sp_ssex=new SqlParameter("@ssex",strsex);*/
using (SqlCommand con = new SqlCommand(ss.strcon))
{
con.Open();
using (SqlCommand cmd = new SqlCommand(strsql, con))
{
cmd.Parameters.Add(sp_tno);
cmd.Parameters.Add(sp_cno);
cmd.Parameters.Add(sp_rnum);
cmd.Parameters.Add(sp_seat);
cmd.Parameters.Add(sp_way);
}
}
}
}
}
代码没有写完