INSERT INTO via SELECT in vb.net oledb (1 Viewer)

PhilBear

New member
Local time
Yesterday, 21:58
Joined
Sep 7, 2004
Messages
6
I am using OLEDB to connect to a Microsoft Access Database.

There are three temp tables (Temp1, Temp2, Temp3) and a Properties table.

I want to insert all results from a search of the Properties table where PropertyCode has a specific value.

In MS Access I can do this with

INSERT INTO Temp1 ( HerbNameLink )
SELECT Properties.HerbOilLink
FROM Properties, Temp1
WHERE (((Properties.PropertyDescriptionIndex)=33));

... 33 is one of the property code values .. .the field is a numeric.

How do I get this into VB.NET (and it must be vb.net code ... not just vb - there is a difference)?


Here is some code I have tried but it doesn't insert any rows into the table Temp1

Decodeddb="mypassword"

Dim strconnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & My.Application.Info.DirectoryPath & "\data\MHR.mdb';Persist Security Info=True;Jet OLEDB:Database Password=" & Decodeddb

Dim PopulateTemp1 As String = ""

PopulateTemp1 = "INSERT INTO Temp1 (HerbNameLink) SELECT Case Properties.HerbOilLink FROM Properties WHERE (((Properties.PropertyDescriptionIndex)=33));"

Dim Resultsconn As New OleDb.OleDbConnection(strResultsConnection)
Dim DA_Results As New OleDb.OleDbDataAdapter(strResultsSQL, Resultsconn)
Dim DS_Results As New DataSet()
DA_Results.InsertCommand = New OleDb.OleDbCommand(PopulateTemp1)



Thanks in advance
Phil
 

Users who are viewing this thread

Top Bottom