Home > Net >  C # Excel in a database
C # Excel in a database

Time:10-03

At present can be imported, given the data repeat, would like to import reading Excel when a field to determine whether exist in SQL sever, delete, and then poured into the new data,
The source code is as follows: string strConn="the database connection";
SqlConnection Conn=new SqlConnection (strConn);
String strSql="select * from Table";

Try
{
The DataSet ds1=new DataSet ();
Conn. The Open ();
SqlDataAdapter adapter=new SqlDataAdapter (strSql, strConn);
SqlCommandBuilder sqlCB1=new SqlCommandBuilder (adapter);
Adapter. The Fill (ds1);

The foreach (DataRow Dr In ds. Tables [0]. Rows)
{

Dr1 (" ID "SQL]=Dr [r]." Excel ID "ToString ();
,
,
,

Ds1. Tables [0]. Rows. The Add (dr1);
}


Adapter. Update (ds1);

Insert MessageBox. Show (" successful ");
}

CodePudding user response:

Send the wrong section, teenagers, to.net or c # section
  • Related