473,785 Members | 2,573 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comma Delimited File & Microsoft.Jet.O LEDB.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.O LEDB.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 'OleDbDataAdapt er':

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=Micro soft.Jet.OLEDB. 4.0;Data
Source=C:\\data \\; Extended Properties=\"Te xt;HDR=YES;\"";

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

// fill data set
string strSql = "SELECT * FROM datafile.txt";
OleDbDataAdapte r oDA = new OleDbDataAdapte r( 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 21849
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(ByVa l sender As Object, _
ByVal e As System.EventArg s) 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=Micro soft.Jet.OLEDB. 4.0;Data Source=" & _
path & ";Extended Properties=""Te xt;HDR=No;FMT=D elimited\"""
Dim conn As New OleDb.OleDbConn ection(ConStr)
Dim da As New OleDb.OleDbData Adapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show (ex.ToString)
End Try
DataGrid1.DataS ource = 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.co m (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.O LEDB.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 'OleDbDataAdapt er':
¤
¤ 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=Micro soft.Jet.OLEDB. 4.0;Data
¤ Source=C:\\data \\; Extended Properties=\"Te xt;HDR=YES;\"";
¤
¤ // open connection
¤ OleDbConnection oCon = new OleDbConnection (strConString);
¤ oCon.Open();
¤
¤ // fill data set
¤ string strSql = "SELECT * FROM datafile.txt";
¤ OleDbDataAdapte r oDA = new OleDbDataAdapte r( 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******@amerit ech.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
387
by: Job Lot | last post by:
Using VB.NET how can I convert access table to tab delimited text file? Thanks
3
5433
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, replacing the old. I naurally know that we can use to kill the other data, but does anyone have any examples of importing a comma delimited file into SQL Server with ASP?
0
1824
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 ---------------------------------------------------- System.Data.OleDb.OleDbException: No error information available: E_NOINTERFACE(0x80004002). ---------------------------------------------------- I have the schema.ini file in the folder with the delimited text file
4
1453
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 2,60000 3,34000 4,780000
3
1870
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 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
1
3133
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 strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strAppPath + "\\mydb.mdb"; OleDbConnection conn = new OleDbConnection(strConn);
15
9560
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(). Basically, this is what I want to do: Use string.Split() on the whole string UNLESS the string is in between double-quotes. The part of the string in-between the "" will be ignored by String.Split Thanks.
1
8188
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, CL10.9, ALLOY STEEL 00002|NO BRAND NAME ASSIGNED|6DU28|M3-.5 X 8 FLAT HD SOCKET CAP SCREW,
0
1700
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 have one letter in the customerID field (M123456). The field they are going into is VARCHAR(1000) . All of the integers go in correctly but for some reason the cutomerID values that stert with a letter (M123456) are NULL. Any help? I'm stumped. ...
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9485
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
10356
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
10161
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8986
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
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
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.