Insert into payroll 2019 select * from "+ ds. Tables [0]
Execution error, "object name" Sheet1 "null and void,"
Excuse me, what's the matter, in this way the query, inserted into the database table can?
CodePudding user response:
Insert into payroll (2019 a, b, c) the value (', ', ')//ABC is the column name like thisCodePudding user response:
????Select into
Is the normal writing, you can baidu "select into" have a more detailed explanation
CodePudding user response:
TheInstert into standard is
Insert into Table2 (field1, field2,... ) select value1, value2,... The from Table1
CodePudding user response:
Your idea is good, it's a pity that the grammar does not support theBut you can write that
public int SqlCopySource (string connString, DataTable table, string name)
{
SqlConnection conn=new SqlConnection (connString);
Conn. The Open ();
Using (SqlBulkCopy bulk=new SqlBulkCopy (conn))
{
Bulk. BatchSize=table. Rows. Count;
Bulk. DestinationTableName=name;
Try
{
Bulk. The WriteToServer (table);
return 1;
}
Catch
{
return -1;
}
The finally
{
Bulk. The Close ();
Conn. Close ();
Conn. The Dispose ();
}
}
}
CodePudding user response:
But above all is the SQL statement, and you say "memory table", has been out of SQL categoryCan only say a dt data is copied to another dt, then in the dt insert structure, update statement, save
So, if is memory table datatble, do not have conditions, or loop one a insert, or use the
The DataTable inserts=table. GetChanges (DataRowState. Added).
Adapter. Update (inserts);
Overall update
Words, adapter adapter with less, general ORM do
CodePudding user response:
Memory table, is that the datatable, dt. Rows [I] Cell [j].