[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Inserting records into table from previous query results

Hi Experts:
Im trying to write some code that will take the results of a query and use those results to insert them into a new table in SQL05, not to sure how to accomplish this. Do I need a SQLAdapter? Do I need to save the results of the query into a dataset and use the dataset to populate the table?
Any help or ideas will be of great help. Im new to vb.net so some code example will be of great help.
This is the part of the code that I have so far:
...

Dim SQL3 As String = "SELECT FIL1, FIL2,FIL3,FIL4 FROM activitydetail where activity_id > " & CStr(minActivityID) & " and activity_id <= " & CStr(maxActivityID) & " and customer_id = 1"
' Create command object
Dim cmd3 As New OdbcCommand(SQL3)
cmd3.Connection = TVconn
' Call command's ExecuteReader
Dim reader3 As OdbcDataReader = cmd3.ExecuteReader()

&&&Next I will like to take those results which are about 7,000 rows and insert them into a new table in SQL05.

Thanks
0
Oneill0003
Asked:
Oneill0003
1 Solution
 
Bob LearnedCommented:
If you have 2005, then I would use an OdbcDataAdapter, and call the Fill method to get a DataTable, and then use the SqlBulkCopy class to write the DataTable to SQL Server.

Bob
0
 
Oneill0003Author Commented:
Thanks!
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now