My code below executes a SELECT...INTO...FROM query using an Access connection. If I run the SQL directly in Access, it works perfectly. If it runs in VB, it creates the new table but does not populate it.
I've tried creating the table then using an INSERT INTO statement to supply the data, but that is not working either in VB.
Both ways do not throw any errors. ExecuteNonQuery is returning 0 rows affected.
If anyone can supply any help it would be greatly appreciated. I'm pulling what's left of my hair straight out of my head!
To note: Where you see '..., there is a bunch of other SQL statements (some that are SELECT...INTO...FROM's) and they all work perfectly. This is the only time an append statement will not work.
I've tried creating the table then using an INSERT INTO statement to supply the data, but that is not working either in VB.
Both ways do not throw any errors. ExecuteNonQuery is returning 0 rows affected.
If anyone can supply any help it would be greatly appreciated. I'm pulling what's left of my hair straight out of my head!
Code:
Dim check As Integer
Dim accessPath As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source = " & _
"C:\Users\Desktop\CustomersInformation.mdb;"
Dim Conn As New System.Data.OleDb.OleDbConnection
Conn = New System.Data.OleDb.OleDbConnection(accessPath)
Conn.Open()
Dim Cmd As System.Data.OleDb.OleDbCommand
'...
Dim SQL As String = "SELECT CustomerShipTo.[Name], CustomerShipTo.[CustomerID] INTO Temp_PriorityShipping_T " _
& "FROM CustomerShipTo GROUP BY CustomerShipTo.[Name], CustomerShipTo.[CustomerID] " _
& "HAVING (((CustomerShipTo.[Name]) Like '*world*'"
Cmd = New System.Data.OleDb.OleDbCommand(SQL, Conn)
Try
check = Cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message.ToString)
Exit Sub
End Try
Conn.close()
To note: Where you see '..., there is a bunch of other SQL statements (some that are SELECT...INTO...FROM's) and they all work perfectly. This is the only time an append statement will not work.