473,837 Members | 1,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error trying to use ODBC Connection with .csv File?

I am using following connection string to get data from a .csv file using
vb.net

strConnstr = "Driver={Micros oft Text Driver (*.txt; *.csv)};Dbq=" +
System.IO.Path. GetDirectoryNam e(sFileName) + ";"
It gives me following error on this line

da.Fill(DS, "Test")
Following is the error message and stack trace

=============Er ror Message ==============
NO_DATA - no error information available"
=============St ackTrace ==============
" at System.Data.Odb c.OdbcConnectio n.HandleError(H andleRef hrHandle,
SQL_HANDLE hType, RETCODE retcode)
at System.Data.Odb c.OdbcDataReade r.GetData(Int32 i, SQL_C sqlctype, Int32
cb)
at System.Data.Odb c.OdbcDataReade r.internalGetSt ring(Int32 i)
at System.Data.Odb c.OdbcDataReade r.GetValue(Int3 2 i, TypeMap typemap)
at System.Data.Odb c.OdbcDataReade r.GetValue(Int3 2 i)
at System.Data.Odb c.OdbcDataReade r.GetValues(Obj ect[] values)
at System.Data.Com mon.SchemaMappi ng.LoadDataRow( Boolean clearDataValues ,
Boolean acceptChanges)
at System.Data.Com mon.DbDataAdapt er.FillLoadData Row(SchemaMappi ng mapping)
at System.Data.Com mon.DbDataAdapt er.FillFromRead er(Object data, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords,
DataColumn parentChapterCo lumn, Object parentChapterVa lue)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Com mon.DbDataAdapt er.FillFromComm and(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, String srcTable)
at OpenUrl.Form1.F illCSVData(Stri ng sFileName) in C:\VB.Net
Downloads\Savin g Web Page\Form1.vb:l ine 313"

I know its one column which has data and null values for some rows? If i
delete that column than it works fine, i need to read values from that column.

Any suggestion, help, advice would be highly appreciated
Mitesh


Nov 21 '05 #1
2 7849
Hi,

Here is an quick example.
If Not Directory.Exist s("C:\CSV Test") Then
Directory.Creat eDirectory("C:\ CSV Test")

'

' Create a csv file

'

Dim sw As New StreamWriter("C :\CSV Test\Test.csv", False)

sw.WriteLine("C olumn1,Column2, Column3")

For x As Integer = 0 To 20

sw.WriteLine("{ 0},{0},{0}", x)

Next

sw.Close()

'

' Open an oledb connection and show it in a datagrid

'

Dim strConn As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=C:\CSV
Test;Extended Properties=""te xt;HDR=Yes;FMT= Delimited"""

Dim conn As New OleDb.OleDbConn ection(strConn)

Dim da As OleDb.OleDbData Adapter

Dim ds As New DataSet

Dim mycmd As New OleDb.OleDbComm and("Select * from Test.csv", conn)

Try

da = New OleDb.OleDbData Adapter(mycmd)

da.Fill(ds)

Catch ex As Exception

Trace.WriteLine (ex.ToString)

Return

End Try

DataGrid1.DataS ource = ds.Tables(0)

DataGrid1.Capti onText = "CSV Test"

Ken

------------------------------

"Mits" <Mi**@discussio ns.microsoft.co m> wrote in message
news:EC******** *************** ***********@mic rosoft.com...
I am using following connection string to get data from a .csv file using
vb.net

strConnstr = "Driver={Micros oft Text Driver (*.txt; *.csv)};Dbq=" +
System.IO.Path. GetDirectoryNam e(sFileName) + ";"
It gives me following error on this line

da.Fill(DS, "Test")
Following is the error message and stack trace

=============Er ror Message ==============
NO_DATA - no error information available"
=============St ackTrace ==============
" at System.Data.Odb c.OdbcConnectio n.HandleError(H andleRef hrHandle,
SQL_HANDLE hType, RETCODE retcode)
at System.Data.Odb c.OdbcDataReade r.GetData(Int32 i, SQL_C sqlctype, Int32
cb)
at System.Data.Odb c.OdbcDataReade r.internalGetSt ring(Int32 i)
at System.Data.Odb c.OdbcDataReade r.GetValue(Int3 2 i, TypeMap typemap)
at System.Data.Odb c.OdbcDataReade r.GetValue(Int3 2 i)
at System.Data.Odb c.OdbcDataReade r.GetValues(Obj ect[] values)
at System.Data.Com mon.SchemaMappi ng.LoadDataRow( Boolean clearDataValues ,
Boolean acceptChanges)
at System.Data.Com mon.DbDataAdapt er.FillLoadData Row(SchemaMappi ng
mapping)
at System.Data.Com mon.DbDataAdapt er.FillFromRead er(Object data, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords,
DataColumn parentChapterCo lumn, Object parentChapterVa lue)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Com mon.DbDataAdapt er.FillFromComm and(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, String
srcTable)
at OpenUrl.Form1.F illCSVData(Stri ng sFileName) in C:\VB.Net
Downloads\Savin g Web Page\Form1.vb:l ine 313"

I know its one column which has data and null values for some rows? If i
delete that column than it works fine, i need to read values from that
column.

Any suggestion, help, advice would be highly appreciated
Mitesh



Nov 21 '05 #2
Hi,

Here is an quick example.
If Not Directory.Exist s("C:\CSV Test") Then
Directory.Creat eDirectory("C:\ CSV Test")

'

' Create a csv file

'

Dim sw As New StreamWriter("C :\CSV Test\Test.csv", False)

sw.WriteLine("C olumn1,Column2, Column3")

For x As Integer = 0 To 20

sw.WriteLine("{ 0},{0},{0}", x)

Next

sw.Close()

'

' Open an oledb connection and show it in a datagrid

'

Dim strConn As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=C:\CSV
Test;Extended Properties=""te xt;HDR=Yes;FMT= Delimited"""

Dim conn As New OleDb.OleDbConn ection(strConn)

Dim da As OleDb.OleDbData Adapter

Dim ds As New DataSet

Dim mycmd As New OleDb.OleDbComm and("Select * from Test.csv", conn)

Try

da = New OleDb.OleDbData Adapter(mycmd)

da.Fill(ds)

Catch ex As Exception

Trace.WriteLine (ex.ToString)

Return

End Try

DataGrid1.DataS ource = ds.Tables(0)

DataGrid1.Capti onText = "CSV Test"

Ken

------------------------------

"Mits" <Mi**@discussio ns.microsoft.co m> wrote in message
news:EC******** *************** ***********@mic rosoft.com...
I am using following connection string to get data from a .csv file using
vb.net

strConnstr = "Driver={Micros oft Text Driver (*.txt; *.csv)};Dbq=" +
System.IO.Path. GetDirectoryNam e(sFileName) + ";"
It gives me following error on this line

da.Fill(DS, "Test")
Following is the error message and stack trace

=============Er ror Message ==============
NO_DATA - no error information available"
=============St ackTrace ==============
" at System.Data.Odb c.OdbcConnectio n.HandleError(H andleRef hrHandle,
SQL_HANDLE hType, RETCODE retcode)
at System.Data.Odb c.OdbcDataReade r.GetData(Int32 i, SQL_C sqlctype, Int32
cb)
at System.Data.Odb c.OdbcDataReade r.internalGetSt ring(Int32 i)
at System.Data.Odb c.OdbcDataReade r.GetValue(Int3 2 i, TypeMap typemap)
at System.Data.Odb c.OdbcDataReade r.GetValue(Int3 2 i)
at System.Data.Odb c.OdbcDataReade r.GetValues(Obj ect[] values)
at System.Data.Com mon.SchemaMappi ng.LoadDataRow( Boolean clearDataValues ,
Boolean acceptChanges)
at System.Data.Com mon.DbDataAdapt er.FillLoadData Row(SchemaMappi ng
mapping)
at System.Data.Com mon.DbDataAdapt er.FillFromRead er(Object data, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords,
DataColumn parentChapterCo lumn, Object parentChapterVa lue)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Com mon.DbDataAdapt er.FillFromComm and(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, String
srcTable)
at OpenUrl.Form1.F illCSVData(Stri ng sFileName) in C:\VB.Net
Downloads\Savin g Web Page\Form1.vb:l ine 313"

I know its one column which has data and null values for some rows? If i
delete that column than it works fine, i need to read values from that
column.

Any suggestion, help, advice would be highly appreciated
Mitesh



Nov 21 '05 #3

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

Similar topics

1
5043
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
2
13648
by: GitarJake | last post by:
Hello all, I am trying to test an ODBC connection to an Oracle dbf using the ODBC Data Source Administrator. It's not working and I suspect I haven't configured Oracle correctly. Below is the error message I am getting: Invalid attribute in connection string: Description.ORA-12514: TNS:listener could not resolve SERVICE_NAME given in connect descriptor
6
10154
by: Rowan | last post by:
Hello, I have been trying to solve this problem for a couple of weeks now with no progress. I created a package that works when it runs from my computer but when it runs as a scheduled job, it fails. I found references to this quite a few times and the responses have always pointed to permissions, but I am a System Administrator. My role is Sysadmin. I changed the Windows/NT owner of the job to sa and that didn't work either. I made...
2
2289
by: Chuck Ritzke | last post by:
Hi all, I am getting an intermittant error after uploading a project from my development machine. I click on a link which opens an aspx page that, upon page load, reads a very small amount of data from an MS Access database, using ODBC and a stored query. There is no problem on my development machine. On the production server though, I get the intermittant error shown below. If I click back and forth between the problem page and the...
0
1221
by: Marlon | last post by:
I got the error message below when I try to open a connection with code: Dim connection As New OdbcConnection("Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=C:\Inetpub\aesd") connection.Open() I am developing an asp.net application on Windows XP SP2. Can anyone help? Personal I think it is because of the limited permissions that asp.net account has.
0
294
by: Mits | last post by:
I am using following connection string to get data from a .csv file using vb.net strConnstr = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + System.IO.Path.GetDirectoryName(sFileName) + ";" It gives me following error on this line da.Fill(DS, "Test")
0
12077
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in '/CinemaBookingSystem' Application. -------------------------------------------------------------------------------- ERROR General error Unable to open registry key 'Temporary (volatile) Jet DSN for process
1
2827
by: dryajov | last post by:
Hi I'm not sure if this should go here in the first place, this is more likely an ODBC driver issue. I'm having the strangest behavior when trying to do an insert into an access database from a C++ application, thru ODBC. I'm able to successfully open a connection to the DB and perform selects, but when I try to do an insert the strangest thing happens, ODBC throws an error saying that it can't open the "dba.mdb" file, which is not the db...
9
7133
by: Martin | last post by:
Using ODBC in a PHP script, I'm trying to read an MS Access MDB file that resides on another computer on my LAN. I'm getting the error: Warning: odbc_connect() : SQL error: The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data., SQL state S1000 in SQLConnect in ... The file is NOT already opened exclusively (or in any other manner)...
0
9682
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10875
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10272
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9401
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7001
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5848
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4040
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3124
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.