473,406 Members | 2,713 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,406 software developers and data experts.

Comma Delimited File & Microsoft.Jet.OLEDB.4.0 provider

TF
Hi,
I have to access data from a comma delimited file in .net windows
application (VB.net or C#). I am using Microsoft.Jet.OLEDB.4.0
provider for this purpose. Now the problem is when i extract data from
a file with extension csv or txt it works fine but as soon as i change
the extension, like 'log' or 'abc' it gives following error in 'Fill'
function of 'OleDbDataAdapter':

Cannot update. Database or object is read-only

I've added file entry in 'schema.ini' file, also I've created a dummy
System DSN and added new extension 'log' in it, but no success.

Here is the code:

//--------------------------------------------
string strConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\data\\; Extended Properties=\"Text;HDR=YES;\"";

// open connection
OleDbConnection oCon = new OleDbConnection(strConString);
oCon.Open();

// fill data set
string strSql = "SELECT * FROM datafile.txt";
OleDbDataAdapter oDA = new OleDbDataAdapter( strSql, oCon );
DataSet oData = new DataSet();
oDA.Fill( oData, datafile.txt ); // -- error if file extension is
log

oCon.Close();
//---------------------------------------------

Any help??
TF
Jul 21 '05 #1
3 21801
Cor
Hi TF,

Can you look at this sample I have made.
The delimiter has to be in your culture setting standard otherwise you have
to play with it.

I hope this helps?

Cor
\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
DataGrid1.DataSource = ds.Tables(0)
End Sub
///
Jul 21 '05 #2
TF
Thanks Cor
Jul 21 '05 #3
On 23 Feb 2004 06:33:01 -0800, fa****@coned.com (TF) wrote:

¤ Hi,
¤ I have to access data from a comma delimited file in .net windows
¤ application (VB.net or C#). I am using Microsoft.Jet.OLEDB.4.0
¤ provider for this purpose. Now the problem is when i extract data from
¤ a file with extension csv or txt it works fine but as soon as i change
¤ the extension, like 'log' or 'abc' it gives following error in 'Fill'
¤ function of 'OleDbDataAdapter':
¤
¤ Cannot update. Database or object is read-only
¤
¤ I've added file entry in 'schema.ini' file, also I've created a dummy
¤ System DSN and added new extension 'log' in it, but no success.
¤
¤ Here is the code:
¤
¤ //--------------------------------------------
¤ string strConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
¤ Source=C:\\data\\; Extended Properties=\"Text;HDR=YES;\"";
¤
¤ // open connection
¤ OleDbConnection oCon = new OleDbConnection(strConString);
¤ oCon.Open();
¤
¤ // fill data set
¤ string strSql = "SELECT * FROM datafile.txt";
¤ OleDbDataAdapter oDA = new OleDbDataAdapter( strSql, oCon );
¤ DataSet oData = new DataSet();
¤ oDA.Fill( oData, datafile.txt ); // -- error if file extension is
¤ log
¤
¤ oCon.Close();
¤ //---------------------------------------------
By default the Text ISAM driver is only set up to support specific file extensions. Modifying the
Registry or renaming the file temporarily will resolve the issue. See the following MS KB article
for more info:

ACC2000: Importing or Linking a Text File Fails for a File That Does Not Have a Valid File Name
Extension
http://support.microsoft.com/default...b;en-us;304206
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Jul 21 '05 #4

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

Similar topics

1
by: Job Lot | last post by:
Using VB.NET how can I convert access table to tab delimited text file? Thanks
3
by: Elmo Watson | last post by:
I've been asked to develop a semi-automated type situation where we have a database table (sql server) and periodically, there will be a comma delimited file from which we need to import the data,...
0
by: TJS | last post by:
attempting to read a delimited text file into a dataset using oledb text file connection getting this error message when trying to open connection...
4
by: Luis Esteban Valencia | last post by:
Hello. I have a method that receives a customer number, and it must return the customer credit which is in a file. like this. So if the parameter is 1, it must give me 450000. 1,450000...
3
by: TF | last post by:
Hi, I have to access data from a comma delimited file in .net windows application (VB.net or C#). I am using Microsoft.Jet.OLEDB.4.0 provider for this purpose. Now the problem is when i extract...
1
by: jj | last post by:
I have this comma delimited text file. I want to convert it in one sweep to an access DB (mdb) format. I used the following code but it takes forever to convert. Is there a faster way? string...
15
by: VMI | last post by:
I'm parsing a comma-delimited record but I want it to do something if some of the string is between "". How can I do this? With the Excel import it does it correct. I'm using String.Split()....
1
by: Fordraiders | last post by:
vb.net 2003 Office 2003 What I have: C:\TestData\Input.txt Text File Pipe Delimited : 4 columns Of data example: 00001|NO BRAND NAME ASSIGNED|6DU27|M3-.5 X 6 FLAT HD SOCKET CAP SCREW,...
0
by: wisaunders | last post by:
the file I'm importing has > 200,000 records I have one problem: One of the columns in the .txt file (customerID) has almost all Inetger values except for about 30 records. Those 30 records...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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
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...
0
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...

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.