Is it possible to fill a data table from another data table by SQL QUERY in VB.net -


i have data table (dtexcelsource) filled ms_excel, using oledb. have second data table, structured (sqldbtype.structured).

my requirement is, fill second data table few values data table(dtexcelsource) using query or other method.

 myconnection = new oledb.oledbconnection("provider=microsoft.ace.oledb.12.0;data source=" & filepath & ";extended properties=""excel 12.0 xml;hdr=no"";")             myconnection.open()             dtexcelschema = myconnection.getoledbschematable(oledbschemaguid.tables, nothing)             dim sheetname string = dtexcelschema.rows(0)("table_name").tostring()             mycommand = new oledb.oledbdataadapter("select * [" & sheetname & "a5:f85]", myconnection)             ds = new system.data.dataset()             mycommand.fill(ds, "sourcetbl")             dtexcelsource = ds.tables("sourcetbl")             'dtexcelsource.columns(0).datatype = gettype(integer)             dtexcelsource.columns(0).columnname = "serial"             dtexcelsource.columns(1).columnname = "document a"             dtexcelsource.columns(2).columnname = "contract a"             dtexcelsource.columns(3).columnname = "subscriber a"             dtexcelsource.columns(4).columnname = "document b"        return dtexcelsource 

my second data table having 15 columns, want insert each rows second data table.

does second table have same structure of first?
when said

my requirement is, fill second data table few values data table(dtexcelsource)

did mean wanted pull rows source table copy in second table or columns?

here @ may said post little confusing me.

   private sub fillseconddatatable()             dim dtexcelsource new datatable             dim dtsecondtable new datatable             ' put code populates dtexcelsource  in function returns datatable             dtexcelsource = somefunctioncalltoyourcode()             'if comes act on             if dtexcelsource isnot nothing andalso dtexcelsource.rows.count > 0                     'i'm cloning dtescelsource structure                     'new table because couldn't understand                      'post                     dtsecondtable = dtexcelsource.clone                     'the select procedure datatables returns                     'an array of datarows                      dim arreturnedrows() datarow = nothing                     'call select filter down rows want                     arreturnedrows = dtexcelsource.select("serial = someserialvalue")                     if arreturnedrows isnot nothing andalso arreturnedrows.count > 0                             'spin through returned rows ,                             'import row second table.                             '1 row cannot belong multiple tables                             'can't add second table while                             'it belongs first table                             each rw datarow in arreturnedrows                                     dtsecondtable.importrow(rw)                             next                     end if             end if     end sub 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -