Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Read dBase in asp.net

Reply
Thread Tools

Read dBase in asp.net

 
 
David C
Guest
Posts: n/a
 
      10-02-2009
I have a web application that needs to read several dBase files created by a
user application. I can read them and display display them in a GridView
just fine using the code example below.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim sConnectionString As String
Dim strSQL As String = "SELECT * FROM " & "1KGI0CYV"

sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\ltserver\Apps\Pathways\Data\extcomm\emsou t\;Extended
Properties=dBase IV"
Dim objConn As New
System.Data.OleDb.OleDbConnection(sConnectionStrin g)
objConn.Open()

Dim da As New System.Data.OleDb.OleDbDataAdapter(strSQL, objConn)

Dim ds As New DataSet("1KGI0CYV")

da.Fill(ds, "1KGI0CYV")

Dim dt As DataTable
dt = ds.Tables("1KGI0CYV")
gvEnvFiles.DataSource = dt

gvEnvFiles.DataBind()

objConn.Close()

End Sub

The problem is that each dBase file has to be renamed with a .dbf extension
for the above to work.
The example file above is named 1KGI0CYV.env and I would like to open it
without renaming it, if possible.
When I try to add the file name to the Data Source= parameter it fails with
the error "... is not a valid path."

Thanks.
David


 
Reply With Quote
 
 
 
 
David C
Guest
Posts: n/a
 
      10-02-2009

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "David C" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> The example file above is named 1KGI0CYV.env and I would like to open it
>> without renaming it, if possible.

>
> It's been a while but, AFAICR, this is not possible and what you are
> seeing is expected behaviour...
>
> With dBase, the folder in which the dbf files resides is considered to be
> the database and the individual dbf files are considered to be the tables.
>
> So, when you point at a dbf file, the OleDb driver strips of ".dbf" from
> the filename and then considers that whatever's left is the database. In
> your case, this won't work i.e. Database =
> "C:\1KGI0CYV.env".Replace(".dbf", "") means that the OleDb provider is now
> looking for a folder called "C:\1KGI0CYV.env", which doesn't exist...
>
>
>> When I try to add the file name to the Data Source= parameter it fails
>> with the error "... is not a valid path."

>
> Indeed so.
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net


Thank you. I thought this was the case since I had no luck with everything I
tried.

Will I run into problems if I rename each file just before opening it, then
naming it back to the original name? I sometimes have an issue with the web
server "catching up" with files when moved, deleted or renamed when I do
something in the same page (file caching issue???) and the same directory.
This user application creates about 15 dbf files with different extensions,
but the same file name. For example 1KGI0CYV.env, 1KGI0CYV.lin,
1KGI0CYV.ttl, etc.

Thanks.
David


 
Reply With Quote
 
 
 
 
Gregory A. Beamer
Guest
Posts: n/a
 
      10-02-2009
"David C" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> The problem is that each dBase file has to be renamed with a .dbf
> extension for the above to work.
> The example file above is named 1KGI0CYV.env and I would like to open
> it without renaming it, if possible.
> When I try to add the file name to the Data Source= parameter it fails
> with the error "... is not a valid path."


It appears the Jet Provider for dBase does not allow anything other than
the default naming, so you need to figure out if there is another provider
that allow other naming conventions. Perhaps this will work for you?
http://www.vistasoftware.com/

As far as the "default" or "normal" method for ISAM databases, it is a
directory with multiple files. Apparently, the jet Provider has the .dbf
hard coded. I am not sure if there is any way around this.

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update a dBase dbf-7 table using OleDB .NET Aurelio ASP .Net 0 01-02-2006 08:13 PM
Import to dbase via excel Vishal ASP .Net 8 11-30-2004 05:41 PM
insert new record in Access dbase AND retrieve autonumber loreille ASP .Net 1 10-28-2004 06:57 PM
re:insert new record in Access dbase AND retrieve autonumber loreille ASP .Net 0 10-28-2004 02:55 PM
define style sheet with data drom dbase nicholas ASP .Net 2 10-07-2004 05:19 PM



Advertisments