Home > Net >  How to query data memory table
How to query data memory table

Time:10-06

Has a list of the definition of the ds and ds inside already has data, now I want to take out the memory in the table data query is inserted into the payroll in 2019, the
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 this

CodePudding user response:

????

Select into

Is the normal writing, you can baidu "select into" have a more detailed explanation

CodePudding user response:

The
Instert 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 the
But 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 category

Can 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].
  •  Tags:  
  • C#
  • Related