Connection error while connecting to TXT file


Hi,

I want to connect to tab delimited txt database file while page loading using following code.  I am getting following error.

"Could not find installable ISAM." Please advise.

  

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & Server.MapPath("~\EXCEL\") & ";Extensions=txt;")

cn.Open() [[[[[ Getting error here ]]]]]]]

Dim sql As String

sql = "select distinct [Journal] from [Report21.txt]"

Dim dc As New OleDbCommand(sql, cn)Dim dr As OleDbDataReader = dc.ExecuteReader()

DD_JC.Focus()

DD_JC.Items.Add("")

'- Populating the JID in the combo box from the Excel file

If dr.HasRows Then

While dr.Read()

DD_JC.Items.Add(dr("Journal"))

End While

End If

dr.Close()

dc.Dispose()

End Sub

0
vijai_sarath
1/31/2009 8:00:39 AM
asp.net.getting-started 91979 articles. 3 followers. Follow

9 Replies
668 Views

Similar Articles

[PageSpeed] 51

You appear to have mashed together 2 different connection strings into one.  I would use the first one in this list: http://www.connectionstrings.com/textfile.

 

 


Regards Mike
[MVP - ASP/ASP.NET]
My site
0
Mikesdotnetting
1/31/2009 9:08:14 AM

I tried the first option. Got the below error

"System.Collections.ListDictionaryInternal - Could not find installable ISAM"

 

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

Try

Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("~\EXCEL\") & ";Extended Properties=text;HDR=Yes;FMT=Delimited;UID=admin")

cn.Open()

Dim sql As String

sql = "select distinct [Journal] from [Report21.txt]"

Dim dc As New OleDbCommand(sql, cn)Dim dr As OleDbDataReader = dc.ExecuteReader()

 

'- Populating the JID in the combo box from the Excel file

If dr.HasRows Then

'While dr.Read()

dr.Read()

Response.Write(dr(
"Journal"))

'End While

End If

dr.Close()

dc.Dispose()

Catch ex As Exception

Response.Write(ex.Data)

Response.Write(ex.Message)

End Try

End Sub

0
vijai_sarath
2/2/2009 7:07:28 AM

 Hi Friend,

              Just try this.. I have done the Windows updates and have installed all the service packs recommended by Microsoft site.

 

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

Try

Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("~\EXCEL\") & ";Extended Properties=Excel 11.0;HDR=Yes;FMT=Delimited;UID=admin")

cn.Open()

Dim sql As String

sql = "select distinct [Journal] from [Report21.txt]"

Dim dc As New OleDbCommand(sql, cn)Dim dr As OleDbDataReader = dc.ExecuteReader()

 

'- Populating the JID in the combo box from the Excel file

If dr.HasRows Then

'While dr.Read()

dr.Read()

Response.Write(dr(
"Journal"))

'End While

End If

dr.Close()

dc.Dispose()

Catch ex As Exception

Response.Write(ex.Data)

Response.Write(ex.Message)

End Try

End Sub

 Hope it will help..

Happy Programming!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

0
visualselvam
2/2/2009 7:28:44 AM

Try this:

("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("~\EXCEL\") & ";Extended Properties=""text;HDR=Yes;FMT=Delimited"";")

 


Regards Mike
[MVP - ASP/ASP.NET]
My site
0
Mikesdotnetting
2/2/2009 8:15:36 AM

Thanks, I tried this. Now I am getting different error.

"System.Collections.ListDictionaryInternal - No value given for one or more required parameters. "

Report21.txt file is inside Excel folder and has the following TAB delimited records.

Journal Title

AA "Auro Art"

 Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

Try

Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("~\EXCEL\") & ";Extended Properties=""text;HDR=Yes;FMT=Delimited"";")

cn.Open()

Dim sql As String

sql = "select distinct [Journal] from [Report21.txt]"

Dim dc As New OleDbCommand(sql, cn)

Dim dr As OleDbDataReader = dc.ExecuteReader() ---- [[[[[[[[Getting Error Here]]]]]]]]]]

If dr.HasRows Then

dr.Read()

Response.Write(dr(
"Journal"))

End If

dr.Close()

dc.Dispose()

Catch ex As Exception

Response.Write(ex.Data)

Response.Write(ex.Message)

End Try

End Sub

 

0
vijai_sarath
2/2/2009 8:43:29 AM

 Hi Friend,

 First make sure that,if you have used the namespace using System.Collections...

Happy Programming!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 

0
visualselvam
2/2/2009 9:20:30 AM

Hi,

Here has a example. please double check the code: 

using System;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Text;

namespace OLEDBCSVDataSource
{
  class CSVDataExample
  {
    private const string OLE_CONN_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};" + 
            "Extended Properties='text;HDR=Yes;FMT=Delimited'";

    [STAThread]
    static void Main( string[] args )
    {

      string sFileName   = "CSVData.txt";
      string sExecPath   = Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );
      string sDataSource = Path.Combine( sExecPath, sFileName );
      string sConn       = String.Format( OLE_CONN_STRING, sExecPath );

      using ( OleDbConnection conn = new OleDbConnection( sConn ) )
      {
        OleDbCommand cmdSelect = new OleDbCommand( "SELECT * FROM " + sFileName, conn );
        conn.Open();
        OleDbDataReader reader = cmdSelect.ExecuteReader();
         while( reader.Read() )
         {
          int iFieldCount = reader.FieldCount;
          StringBuilder sb = new StringBuilder();
          for( int i = 0; i < iFieldCount; i++ )
          {
            sb.Append( reader.GetValue( i ).ToString() );
             sb.Append( "\t" );
          }
          Console.WriteLine( sb.ToString() );
        }
        reader.Close();
      }
      Console.ReadLine();
    }
  }
}
 Let me know whether that answers your question, or if I've missed something.
Best Regards,
Bober Song
--------------------------------
Please remember to click “Mark as Answer” on the post that helps you
0
Bober
2/4/2009 3:45:23 AM

Thanks, but do you have equivalent vb code.

0
vijai_sarath
2/4/2009 12:40:52 PM

Hi,

Please double check following VB.NET code: 

Imports System 
Imports System.Data 
Imports System.Data.OleDb 
Imports System.IO 
Imports System.Text 

Namespace OLEDBCSVDataSource 
    Class CSVDataExample 
        Private Const OLE_CONN_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};" & "Extended Properties='text;HDR=Yes;FMT=Delimited'" 
        
        &lt;STAThread()&gt; _ 
        Private Shared Sub Main(ByVal args As String()) 
            
            Dim sFileName As String = "CSVData.txt" 
            Dim sExecPath As String = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) 
            Dim sDataSource As String = Path.Combine(sExecPath, sFileName) 
            Dim sConn As String = [String].Format(OLE_CONN_STRING, sExecPath) 
            
            Using conn As New OleDbConnection(sConn) 
                Dim cmdSelect As New OleDbCommand("SELECT * FROM " & sFileName, conn) 
                conn.Open() 
                Dim reader As OleDbDataReader = cmdSelect.ExecuteReader() 
                While reader.Read() 
                    Dim iFieldCount As Integer = reader.FieldCount 
                    Dim sb As New StringBuilder() 
                    For i As Integer = 0 To iFieldCount - 1 
                        sb.Append(reader.GetValue(i).ToString()) 
                        sb.Append(vbTab) 
                    Next 
                    Console.WriteLine(sb.ToString()) 
                End While 
                reader.Close() 
            End Using 
            Console.ReadLine() 
        End Sub 
    End Class 
End Namespace 
 If you have anything unclear, please feel free to let me know directly.
Best Regards,
Bober Song
--------------------------------
Please remember to click “Mark as Answer” on the post that helps you
0
Bober
2/5/2009 2:28:11 AM
Reply:

Similar Artilces:

help. when using Profile GetPropertyValue, I get the following connection error: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure
 Hi,I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property((string)(this.GetPropertyValue("Address1")));When I look at the stack, it is coming from my ProfileWrapper class which adds user address, city, etc.. from a class which inherits fromSystem.Web.Profile.ProfileBase. From the stack, it is calling the System.Web.Profile and crashed when it tries to open a connection atSystem.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObj...

[connect error] Interbase Connect Error
In ODBC connect test is successfully.. but in PowerBuilder 6.5 Database Profiles is displayed error message.. Error Message is SQLSTATE = 40001 [Easysoft][Interbase]Dynamic SQL Error, SQL error code = -91, feature is not supported What means this message? Now I use PowerBuilder 6.5 & Interbase 5.6... Just I choose - Profile Name - Data Source --> This is ODBC DNS..(user DNS) - User ID - Password Does it need more? ...

Error Connecting to .txt File
I am trying to connect to a .txt file that contains student records. I have tried using both of the connection strings below and it still cannot open the file for reading. I have debugged it and it fails on the oleDBConn.open(). Once again, I am new to some of this, but I'm not sure why this isn't working. When I use the Microsoft Text Driver Provider, it tells me that it is not registered on the sysem. Does anybody have an ideas as to where I am messing up. <code> Public Const absPath AS String = "c:\my documents\visual studio projects\addstudentuser\newstudents....

not connected when I am connected
What do I need to change on my 'puter when the icon in the toolbar shows and tells me I am connected and the error message tells me I am not and I can not go to web pages, get or send emails. I have to close down and restart to get connected again. This only happens if I am on line and leave the 'puter for an hour or so. As long as I am using it I don't have a problem. This just started about a month ago. I am on very slow dialup, DSL and Cable not in my area, thanks you SBC/ATT tks Elaine wrote: > What do I need to change on my 'puter when the icon in ...

Why am I getting a cannot connect, database engine not started error?
I have created an .exe file for distribution...however, when i run it i get an error saying it cannot connect to the database, database engine not started. If I open powerbuilder, start the engine, and then run the exe file..it works fine. What am I missing in my exe or project? Thanks in Advance, RC I guess your exe is trying to connect over network and your database server is installed on your development machine. Assuming that you are using ASA, it has an option to tell the db engine to start if its not already started (ODBC DSN properties). This works fine if the app and t...

Connection error
We have see the message: Connection error - An error occurred during the TCPIP connection attempt twice now. The first time was a laptop that had not been used in a while. Now we are seeing the same message while trying to connect to a computer where ASA has just been installed. brian Brian Howard wrote: > We have see the message: > > Connection error - An error occurred during the TCPIP > connection attempt > > twice now. The first time was a laptop that had not been > used in a while. Now we are seeing the same message while > trying to connec...

Connect to LAN (Was connect to NET)
Almost time for a new header, the old was getting too long and the focus is now different. So .... Story so far - Mepis 6 - setting LAN IP would upset external site addressing but the ISP hung in there without dropping the line. I have, at last, succeeded in connecting to the web via dial up AND keeping it running while seeing a LAN. I can't point directly to what I did but I did keep notes along the way as to what NOT to touch. Call it pure luck, deft fingerwork, incantations and imprecations. Next problem - 5 PC's. (5 Machine names) A, B, C, D, E. (4 are Win XP...

Get Connection from connection Cache ???
Hi there, I have created a DataSource in my EJb context, but when I'm performing a lookup a com.sybase.ejb.NamingContext is returned instead of a DataSource object, which means I'm unable to typecast it into a DataSource and perform the getConnection invocation. Code: java.util.Properties props = new java.util.Properties(); props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.sybase.ejb.InitialContextFactory"); props.put(javax.naming.Context.PROVIDER_URL, "iiop://avenir_kpp:9000"); props.put(javax.naming.Context.SECURI...

Connecting to Webservice from smartdevice Application in .net gives an error "could not establish connection to network".
Connecting to Webservice from smartdevice Application in .net gives an error "could not establish connection to network".chsk  Check up the following: 1)Internet connection is on & working. 2)Ping the server where the Webservice is hosted on. 3)Try browsing to the Webservice url using pocket IE. If all this tests works fine - then the problem is in your code.   Goodluck  ...

Getting started with SAMBA: Problem with not being able to connect to file/folder
I have used swerdna‎'s documentation to get started with SAMBA. I am running the server on openSUSE 11.3 (switching to 12.1 here soon). On the server's machine I can access the my home directory. On a Windows 7 machine, I can get to my home directory, change directories, and then create a file. On another Linux machine, also running 11.3, I cannot access my home directory and get the message "The file or folder smb://scott/homes does not exist." Further I was not prompted for a userid/password. Any ideas? The smb.conf file is as follows: # Samba config ...

Internal connection fatal error and other random db connection errors
Hi guys!My newly built website has just recently went online,but sometimes I face errors (randomly) like these: System.IndexOutOfRangeException: There is no row at position 0.System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.System.IndexOutOfRangeException: Cannot find table 0System.NullReferenceException: Object reference not set to an instance of an object.System.InvalidOperationException: ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.System.InvalidOper...

Web Referenced WSDL always getting "The underlying connection was closed: Unable to connect to the remote server." error
I'm getting "Exception Details: System.Net.WebException: The underlying connection was closed: Unable to connect to the remote server." on reference.cs file.I looked up this error and there were fixes for it, if it was occuring intermittently (I applied it anyway without success).  However my error seems to be permanent.  FYI, web service is Java based and client is of course .NET based.  Does it sound like service provider issue?Thanks in advance Java Web Server shouldn't be a problem;There are many reason why this can happen:1.Check if your personal Fir...

Started getting a "Unable to establish secure connection with the server" error
I've been working on revising this ASP.NET 2.0 app for the last couple of days.  We've got Windows XP Professional PCs with SP2 installed, and we do our development on those machines.  Yesterday I was working on some of the .aspx pages, saved the changes and ran them, and everything was just fine.  It worked perfectly.  I authenticated against our Active Directory just fine.  However, today when I tried to test it some more I got the following error message, "Unable to establish secure connection with the server" and it highlights the type attribute...

Why we use Web.Config File for connection string wether we can use class Library for get connection for whole web Application
 Why we use Web.Config File for connection string wether we can use class Library for get connection for whole web Application  please help me? Friend, Web.config has its own advantages. 1) Web.Config is used to store the important information like connections strings etc...so that it can be modified even after the code has been    deployed to the server without compiling the entire application again. 2) Since it is a XML file, there is no need of building the project of you are going to change the connection strings.   If you go for the class files,...

Web resources about - Connection error while connecting to TXT file - asp.net.getting-started

Connection - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

iMedia Connection: Interactive Marketing News, Features, Podcasts and Video - iMediaConnection.com
If you send more email, you might make more money. Then again, you might destroy your reputation and revenue stream. Here's how to know what ...

HTTP persistent connection - Wikipedia, the free encyclopedia
... tacked on to an existing protocol. If the browser supports keep-alive, it adds an additional header to the request: Following this, the connection ...

MOTHER’S DAY: Facebook Examines Connections Between Moms, Kids
With Mother’s Day on the calendar this coming Sunday, Facebook examined the relationships between mothers and their children on the social network, ...

Kings Cross identities arrested in connection with murder
Two Kings Cross identities&nbsp;have been arrested in connection with the murder of a man at Sydney hotel.

Governor declares state of emergency in connection with California methane leak
... of Emergency Services) On Wednesday evening, California Governor Jerry Brown declared a state of emergency in Los Angeles County in connection ...

Tons Of Methane Are Spewing Out Of California, And There’s A Connection To The Governor
The out of control leak has forced thousands of residents to flee their homes. Gov. Brown's sister is a paid board member at the company that ...

Report: Man arrested in connection with Ashley Olsen's murder
Italian media agency reports that a non-EU male has been arrested in the murder of the 35-year-old American

Toyota and Kymeta rely on satellites to power this Mirai's data connection
They're hoping to achieve gigabit wireless speeds within the next few years.

Test Claims To Show T-Mobile’s YouTube “Optimization” Is Just Connection Throttling
... on the same network, and at the same time of day. They tested video streaming against three other kinds of downloads and measured the connection ...

Resources last updated: 1/15/2016 9:19:44 PM