write to csv file odbc

if I have a command text that want to create a new table (report1.csv) from a table the orginal (report.csv), how would I write my query to softcode the file name?
OleComm.CommandText = ("select * into " & mCsvFileName & " from " & mCsvFileName & ")
[303 byte] By [fufu] at [2008-1-8]
# 1

I don't really see anything wrong with the code you are using. Below is a more complete example:

Code Snippet
Dim ConnectionString As String

Dim SourceFile As String = "report.csv"

Dim DestinationFile As String = "report1.csv"

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "E:\My Documents\TextFiles" & ";" & _
"Extended Properties=""Text;HDR=YES;"""

Dim TextConnection As New System.Data.OleDb.OleDbConnection(ConnectionString)

TextConnection.Open()

Dim SQLString As String = "SELECT * INTO " & DestinationFile & " FROM " & SourceFile

Dim TextConnection As New System.Data.OleDb.OleDbCommand(SQLString, TextConnection)

TextConnection.ExecuteNonQuery()

TextConnection.Close()

PaulPClementIV at 2007-10-2 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2

Dear,

Try to use INSERT INTO. This might solve your problem.

Regards,

Wasif Ahmad

ComputerAngel at 2007-10-2 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 3
Btw, i would strongly recommend against concatenating variables into a query...

Code Snippet

oleDbCmd.CommandText = "INSERT INTO x ( column1, column2 ) VALUES ( ?, ? )";
oleDbCmd.Parameters.Add("@value1", OleDbType.Int32).Value = 10;
oleDbCmd.Parameters.Add("@value2", OleDbType.String).Value = "O'Reilly";


timvw at 2007-10-2 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 4

my query "SELECT * INTO " & DesstinationFile & " FROM " & SourceFile &" is in a class, but I want to softcode the file desinationFile and SourceFile in another module. How would I do that?

fufu at 2007-10-2 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified