Reputation: 81
I'm able to select an entire table from an Access database, into a CSV using the following code via VB.NET:
Dim AccessCommandCust As New OleDbCommand("SELECT * INTO [Text;DATABASE=C:\TEMP].[CUSTOMERS.csv] FROM Customers", AccessConn)
However, I don't need the entire table, just two columns -- Firstname and Lastname. The SQL is simple enough, but when I attempt this using the following code:
Dim AccessCommandCust As New OleDbCommand("SELECT FirstName, LastName INTO [Text;DATABASE=C:\TEMP].[CUSTOMERS.csv] FROM Customers", AccessConn)
It raises an exception:
Microsoft Jet database engine could not find the object 'CUSTOMERS.csv').
I'm trying to figure out where I'm going wrong.
Upvotes: 2
Views: 2459
Reputation: 81
The following syntax ended-up working for me:
Dim AccessCommandCust As New System.Data.OleDb.OleDbCommand("SELECT FirstName, LastName INTO [Text;HDR=YES;DATABASE=C:\Temp\].CUSTOMERS.csv FROM Customers", AccessConn)
The brackets [] around the filename itself, appear to be the issue.
Upvotes: 1