473,503 Members | 2,148 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={Microsoft Text Driver (*.txt; *.csv)};Dbq=" +
System.IO.Path.GetDirectoryName(sFileName) + ";"
It gives me following error on this line

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

=============Error Message ==============
NO_DATA - no error information available"
=============StackTrace ==============
" at System.Data.Odbc.OdbcConnection.HandleError(Handle Ref hrHandle,
SQL_HANDLE hType, RETCODE retcode)
at System.Data.Odbc.OdbcDataReader.GetData(Int32 i, SQL_C sqlctype, Int32
cb)
at System.Data.Odbc.OdbcDataReader.internalGetString( Int32 i)
at System.Data.Odbc.OdbcDataReader.GetValue(Int32 i, TypeMap typemap)
at System.Data.Odbc.OdbcDataReader.GetValue(Int32 i)
at System.Data.Odbc.OdbcDataReader.GetValues(Object[] values)
at System.Data.Common.SchemaMapping.LoadDataRow(Boole an clearDataValues,
Boolean acceptChanges)
at System.Data.Common.DbDataAdapter.FillLoadDataRow(S chemaMapping mapping)
at System.Data.Common.DbDataAdapter.FillFromReader(Ob ject data, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords,
DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at OpenUrl.Form1.FillCSVData(String sFileName) in C:\VB.Net
Downloads\Saving Web Page\Form1.vb:line 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 7824
Hi,

Here is an quick example.
If Not Directory.Exists("C:\CSV Test") Then
Directory.CreateDirectory("C:\CSV Test")

'

' Create a csv file

'

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

sw.WriteLine("Column1,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=Microsoft.Jet.OLEDB.4.0;Data Source=C:\CSV
Test;Extended Properties=""text;HDR=Yes;FMT=Delimited"""

Dim conn As New OleDb.OleDbConnection(strConn)

Dim da As OleDb.OleDbDataAdapter

Dim ds As New DataSet

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

Try

da = New OleDb.OleDbDataAdapter(mycmd)

da.Fill(ds)

Catch ex As Exception

Trace.WriteLine(ex.ToString)

Return

End Try

DataGrid1.DataSource = ds.Tables(0)

DataGrid1.CaptionText = "CSV Test"

Ken

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

"Mits" <Mi**@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
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")
Following is the error message and stack trace

=============Error Message ==============
NO_DATA - no error information available"
=============StackTrace ==============
" at System.Data.Odbc.OdbcConnection.HandleError(Handle Ref hrHandle,
SQL_HANDLE hType, RETCODE retcode)
at System.Data.Odbc.OdbcDataReader.GetData(Int32 i, SQL_C sqlctype, Int32
cb)
at System.Data.Odbc.OdbcDataReader.internalGetString( Int32 i)
at System.Data.Odbc.OdbcDataReader.GetValue(Int32 i, TypeMap typemap)
at System.Data.Odbc.OdbcDataReader.GetValue(Int32 i)
at System.Data.Odbc.OdbcDataReader.GetValues(Object[] values)
at System.Data.Common.SchemaMapping.LoadDataRow(Boole an clearDataValues,
Boolean acceptChanges)
at System.Data.Common.DbDataAdapter.FillLoadDataRow(S chemaMapping
mapping)
at System.Data.Common.DbDataAdapter.FillFromReader(Ob ject data, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords,
DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable)
at OpenUrl.Form1.FillCSVData(String sFileName) in C:\VB.Net
Downloads\Saving Web Page\Form1.vb:line 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.Exists("C:\CSV Test") Then
Directory.CreateDirectory("C:\CSV Test")

'

' Create a csv file

'

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

sw.WriteLine("Column1,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=Microsoft.Jet.OLEDB.4.0;Data Source=C:\CSV
Test;Extended Properties=""text;HDR=Yes;FMT=Delimited"""

Dim conn As New OleDb.OleDbConnection(strConn)

Dim da As OleDb.OleDbDataAdapter

Dim ds As New DataSet

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

Try

da = New OleDb.OleDbDataAdapter(mycmd)

da.Fill(ds)

Catch ex As Exception

Trace.WriteLine(ex.ToString)

Return

End Try

DataGrid1.DataSource = ds.Tables(0)

DataGrid1.CaptionText = "CSV Test"

Ken

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

"Mits" <Mi**@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
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")
Following is the error message and stack trace

=============Error Message ==============
NO_DATA - no error information available"
=============StackTrace ==============
" at System.Data.Odbc.OdbcConnection.HandleError(Handle Ref hrHandle,
SQL_HANDLE hType, RETCODE retcode)
at System.Data.Odbc.OdbcDataReader.GetData(Int32 i, SQL_C sqlctype, Int32
cb)
at System.Data.Odbc.OdbcDataReader.internalGetString( Int32 i)
at System.Data.Odbc.OdbcDataReader.GetValue(Int32 i, TypeMap typemap)
at System.Data.Odbc.OdbcDataReader.GetValue(Int32 i)
at System.Data.Odbc.OdbcDataReader.GetValues(Object[] values)
at System.Data.Common.SchemaMapping.LoadDataRow(Boole an clearDataValues,
Boolean acceptChanges)
at System.Data.Common.DbDataAdapter.FillLoadDataRow(S chemaMapping
mapping)
at System.Data.Common.DbDataAdapter.FillFromReader(Ob ject data, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords,
DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable)
at OpenUrl.Form1.FillCSVData(String sFileName) in C:\VB.Net
Downloads\Saving Web Page\Form1.vb:line 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
5011
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...
2
13620
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...
6
10126
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...
2
2254
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...
0
1205
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")...
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) +...
0
12002
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...
1
2802
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...
9
7113
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...
0
7205
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
7093
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...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
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...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4689
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...
0
1521
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 ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
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...

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.