定义了3个文本框.,对insert 数据,,谢谢
public partial class Form2 : Form
{
public string strConnection;
OleDbConnection myConn;
public Form2()
{
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=rats.mdb;"; myConn = new OleDbConnection(strConnection);
InitializeComponent();
//myConn.Open();
} private void label2_Click(object sender, EventArgs e)
{ } private void button2_Click(object sender, EventArgs e)
{
this.Close();
} private void button1_Click(object sender, EventArgs e)
{
string name1, name2, rates;
name1 = textBox1.Text;
name2 = textBox2.Text;
rates = textBox3.Text;
//try{myConn.Open();//设置SQL语句
string insertstr="INSERT INTO RATES(MONEYNAME1,MONEYNAME2,RATES) VALUES (´";
insertstr += name1 +"´, ´";
insertstr += name2 + "´,´";
insertstr += rates +"´)";OleDbCommand insertcmd = new OleDbCommand(insertstr,myConn) ;
insertcmd.ExecuteNonQuery() ;myConn.Close();
//tempvalue=true;
}
//catch(Exception exp)
//{
//throw(new Exception("数据库出错:" )) ;
//}
//return(tempvalue);
//}private OleDbConnection getConn()
{
throw new Exception("The method or operation is not implemented.");
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货