当前位置:数据库 > Excel >>

怎么用mysql语句将excel中的数据导入表中

答案:private void btnOK_Click(object sender, System.EventArgs e) { SqlConnection myConnection = new SqlConnection("Server=(local);Initial Catalog=Northwind;uid=sa;pwd=111;"); myConnection.Open(); // 启动一个事务 SqlTransaction myTrans = myConnection.BeginTransaction(); // 为事务创建一个命令 SqlCommand myCommand = new SqlCommand(); myCommand.Connection=myConnection; myCommand.Transaction = myTrans; try { myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (110, 'Description')"; myCommand.ExecuteNonQuery(); //myTrans.Commit(); myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (111, 'Description')"; myCommand.ExecuteNonQuery(); myTrans.Commit(); Response.Write("成功写入记录!"); } catch(Exception Ex) { myTrans.Rollback(); Response.Write(Ex.ToString()); Response.Write("写入数据库失败!"); } finally { myConnection.Close(); } } 本文来自CSDN博客,转载请标明出处:

上一个:在excel的querytable中做参数查询报错:“parameter子句语法错”。
下一个:将excel表导入到SQL数据库

Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,