473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help with simple query

The first query will run but the second will not:

Dim constring As String
Dim id As String = "10-03"
File.Delete(FilePath & CSVFileName)
constring = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
FilePath & DataBaseFileName)
Dim objadapter As New OleDbDataAdapter

With objadapter
.SelectCommand = New OleDbCommand
.SelectCommand.CommandText = ("SELECT * INTO
[Text;DATABASE=C:\myFiles\].[test.csv] FROM [Interest Group List];")
.SelectCommand.CommandType = CommandType.Text
.SelectCommand.Connection = New OleDbConnection(constring)
.SelectCommand.Connection.Open()
.SelectCommand.ExecuteNonQuery()
.SelectCommand.Connection.Close()
End With
Using this line throws the following error on the ExecuteNonQuery() line:
..SelectCommand.CommandText = ("SELECT[list number] INTO
[Text;DATABASE=C:\myFiles\\].[test.csv] FROM [Interest Group List];")

Error:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred
in system.data.dll

Why do I get a column name into the SELECT? The column name does have a
space and I can't get around that.

Thanks,
Brett
Nov 21 '05 #1
3 1531
Are you sure that the extra space is the issue? You appear to have an extra
\ in the second query also. I would put a Try...Catch blosk around this
code and look at the Exception.Message to get a more detailed error message
description.

"Brett" <no@spam.com> wrote in message
news:ez**************@TK2MSFTNGP12.phx.gbl...
The first query will run but the second will not:

Dim constring As String
Dim id As String = "10-03"
File.Delete(FilePath & CSVFileName)
constring = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
FilePath & DataBaseFileName)
Dim objadapter As New OleDbDataAdapter

With objadapter
.SelectCommand = New OleDbCommand
.SelectCommand.CommandText = ("SELECT * INTO
[Text;DATABASE=C:\myFiles\].[test.csv] FROM [Interest Group List];")
.SelectCommand.CommandType = CommandType.Text
.SelectCommand.Connection = New OleDbConnection(constring)
.SelectCommand.Connection.Open()
.SelectCommand.ExecuteNonQuery()
.SelectCommand.Connection.Close()
End With
Using this line throws the following error on the ExecuteNonQuery() line:
.SelectCommand.CommandText = ("SELECT[list number] INTO
[Text;DATABASE=C:\myFiles\\].[test.csv] FROM [Interest Group List];")

Error:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred
in system.data.dll

Why do I get a column name into the SELECT? The column name does have a
space and I can't get around that.

Thanks,
Brett

Nov 21 '05 #2
No, that was a mistake in my posting. If you try this with the default
Northwind database, it will throw an error:

Dim AccessConn As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;Data
Source=C:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb")

AccessConn.Open()

Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT
unitprice, quantity INTO [Text;DATABASE=C:\test].[Table.csv] FROM [order
details]", AccessConn)

AccessCommand.ExecuteNonQuery()
AccessConn.Close()

Use:
SELECT *
and everything will be fine.

Brett

"Michael C#" <xy*@yomomma.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Are you sure that the extra space is the issue? You appear to have an
extra \ in the second query also. I would put a Try...Catch blosk around
this code and look at the Exception.Message to get a more detailed error
message description.

"Brett" <no@spam.com> wrote in message
news:ez**************@TK2MSFTNGP12.phx.gbl...
The first query will run but the second will not:

Dim constring As String
Dim id As String = "10-03"
File.Delete(FilePath & CSVFileName)
constring = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
FilePath & DataBaseFileName)
Dim objadapter As New OleDbDataAdapter

With objadapter
.SelectCommand = New OleDbCommand
.SelectCommand.CommandText = ("SELECT * INTO
[Text;DATABASE=C:\myFiles\].[test.csv] FROM [Interest Group List];")
.SelectCommand.CommandType = CommandType.Text
.SelectCommand.Connection = New OleDbConnection(constring)
.SelectCommand.Connection.Open()
.SelectCommand.ExecuteNonQuery()
.SelectCommand.Connection.Close()
End With
Using this line throws the following error on the ExecuteNonQuery() line:
.SelectCommand.CommandText = ("SELECT[list number] INTO
[Text;DATABASE=C:\myFiles\\].[test.csv] FROM [Interest Group List];")

Error:
An unhandled exception of type 'System.Data.OleDb.OleDbException'
occurred in system.data.dll

Why do I get a column name into the SELECT? The column name does have a
space and I can't get around that.

Thanks,
Brett


Nov 21 '05 #3
Sorry, I'm not familiar with using OleDb to access or generate CSV files.
Sounds like OleDb doesn't recognize individual column names in a CSV file,
but I'm not sure. Sorry bout that.

"Brett" <no@spam.net> wrote in message
news:uK**************@TK2MSFTNGP15.phx.gbl...
No, that was a mistake in my posting. If you try this with the default
Northwind database, it will throw an error:

Dim AccessConn As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;Data
Source=C:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb")

AccessConn.Open()

Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT
unitprice, quantity INTO [Text;DATABASE=C:\test].[Table.csv] FROM [order
details]", AccessConn)

AccessCommand.ExecuteNonQuery()
AccessConn.Close()

Use:
SELECT *
and everything will be fine.

Brett

"Michael C#" <xy*@yomomma.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Are you sure that the extra space is the issue? You appear to have an
extra \ in the second query also. I would put a Try...Catch blosk around
this code and look at the Exception.Message to get a more detailed error
message description.

"Brett" <no@spam.com> wrote in message
news:ez**************@TK2MSFTNGP12.phx.gbl...
The first query will run but the second will not:

Dim constring As String
Dim id As String = "10-03"
File.Delete(FilePath & CSVFileName)
constring = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
FilePath & DataBaseFileName)
Dim objadapter As New OleDbDataAdapter

With objadapter
.SelectCommand = New OleDbCommand
.SelectCommand.CommandText = ("SELECT * INTO
[Text;DATABASE=C:\myFiles\].[test.csv] FROM [Interest Group List];")
.SelectCommand.CommandType = CommandType.Text
.SelectCommand.Connection = New OleDbConnection(constring)
.SelectCommand.Connection.Open()
.SelectCommand.ExecuteNonQuery()
.SelectCommand.Connection.Close()
End With
Using this line throws the following error on the ExecuteNonQuery()
line:
.SelectCommand.CommandText = ("SELECT[list number] INTO
[Text;DATABASE=C:\myFiles\\].[test.csv] FROM [Interest Group List];")

Error:
An unhandled exception of type 'System.Data.OleDb.OleDbException'
occurred in system.data.dll

Why do I get a column name into the SELECT? The column name does have a
space and I can't get around that.

Thanks,
Brett



Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
5
by: Steve Patrick | last post by:
Hi All You guys are my last hope, despite spending money on books and hours reading them I still can not achieve the results I need. I have designed a database in Access 2000 based on 1 table,...
3
by: Mike | last post by:
I have had alot of problems with my query, I have a two tables of informations and just need a simple Query to get what I want but it is turning out not to be so simple. Table 1 Has the following...
6
by: Mike | last post by:
I have had alot of problems with my query, I have a two tables of informations and just need a simple Query to get what I want but it is turning out not to be so simple. Table 1 Has the following...
1
by: remove | last post by:
Hi all, I have a fairly simple database containing details of broadcast news reports. Each record contains information about the programme title, date, time, presenter, and details of the...
2
by: schoultzy | last post by:
Hello Everyone, This is probably a simple fix so be kind when/if you reply. The query below retrieves information for individuals based on a column named ATTRIB_DEF, and assorted other columns;...
8
by: pamelafluente | last post by:
I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work. This is what I need to accomplish: ---------------------- Given button and a TextBox on a...
2
by: googlegroups.dsbl | last post by:
I'm really confused here, and am wondering if someone knows what could be the issue with my TableAdapter query. A few months ago, I created a really neat program that has th ability to search by...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
3
by: rogynskyy | last post by:
Hi guys, I'm running MSDE 2000 A on Win XP I've got a database with several tables, all of the tables display data in query manager. I wrote this simple query: Select
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.