473,606 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opening a dbf file with .NET code

I have a simple dbf file with the name of OTHWAGE.dbf. I can open it in
Visual Studio Server Explorer and see its fields and records by creating a
Data Connection. When I copy the connection string and combine it with code
from VS Help, I end up with the following:

Dim sConnection As String = "Provider=MSDAS QL.1;
Persist Security Info=False;
Data Source=dBASE Files;
Extended Properties=""DS N=dBASE Files;DBQ=C:\Te mp;
DefaultDir=c:\P rogram Files\Microsoft Visual Studio .NET 2003\Common7\ID E;
DriverId=533;Ma xBufferSize=204 8;
PageTimeout=5
;"";
Initial Catalog=C:\Temp "

Dim mySelectQuery As String = "SELECT OTHWAGE.* FROM OTHWAGE"
Dim myConnection As New System.Data.Odb c.OdbcConnectio n(sConnection)
Dim myCommand As New System.Data.Odb c.OdbcCommand(m ySelectQuery,
myConnection)
myConnection.Op en()
Dim myReader As
System.Data.Odb c.OdbcDataReade r = myCommand.Execu teReader()
While myReader.Read()
Console.WriteLi ne(myReader.Get String(1))
End While

For readability purposes, I added carriage returns to the connection string.
When I execute this code, I get a system error at the myConnection.Op en()
line. What I am I doing wrong with this simple code?
Nov 21 '05 #1
4 14354
Hi Joe,

First off, try the FoxPro and Visual FoxPro OLE DB data provider, available
from http://msdn.microsoft.com/vfoxpro/downloads/updates . For your
connection string use:

"Provider=VFPOL EDB.1;Data Source = C:\Temp;"

That's all you need for free tables. If you still have problems, post back.

--
Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP
ci************* *@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden
"genojoe" <ge*****@discus sions.microsoft .com> wrote in message
news:76******** *************** ***********@mic rosoft.com...
I have a simple dbf file with the name of OTHWAGE.dbf. I can open it in
Visual Studio Server Explorer and see its fields and records by creating a
Data Connection. When I copy the connection string and combine it with
code
from VS Help, I end up with the following:

Dim sConnection As String = "Provider=MSDAS QL.1;
Persist Security Info=False;
Data Source=dBASE Files;
Extended Properties=""DS N=dBASE Files;DBQ=C:\Te mp;
DefaultDir=c:\P rogram Files\Microsoft Visual Studio .NET 2003\Common7\ID E;
DriverId=533;Ma xBufferSize=204 8;
PageTimeout=5
;"";
Initial Catalog=C:\Temp "

Dim mySelectQuery As String = "SELECT OTHWAGE.* FROM OTHWAGE"
Dim myConnection As New
System.Data.Odb c.OdbcConnectio n(sConnection)
Dim myCommand As New System.Data.Odb c.OdbcCommand(m ySelectQuery,
myConnection)
myConnection.Op en()
Dim myReader As
System.Data.Odb c.OdbcDataReade r = myCommand.Execu teReader()
While myReader.Read()
Console.WriteLi ne(myReader.Get String(1))
End While

For readability purposes, I added carriage returns to the connection
string.
When I execute this code, I get a system error at the myConnection.Op en()
line. What I am I doing wrong with this simple code?

Nov 21 '05 #2
I agree it should work. This time I even began a new project (on same
computer). One form, one button. FoxPro provider worked great in the Server
Explorer.

I crash at last line of code shown below:

Dim sConnection As String = "Provider=VFPOL EDB.1;Data Source = C:\Temp;"
Dim mySelectQuery As String = "SELECT OTHWAGE.* FROM OTHWAGE"
Dim myConnection As New System.Data.Odb c.OdbcConnectio n(sConnection)
Dim myCommand As New System.Data.Odb c.OdbcCommand(m ySelectQuery, myConnection)

myConnection.Op en()

Error message is:
An unhandled exception of type 'System.Data.Od bc.OdbcExceptio n' occurred in
system.data.dll

Additional information: System error.

Thank you for the response. Any more thoughts?
=============== ===

"Cindy Winegarden" wrote:
Hi Joe,

First off, try the FoxPro and Visual FoxPro OLE DB data provider, available
from http://msdn.microsoft.com/vfoxpro/downloads/updates . For your
connection string use:

"Provider=VFPOL EDB.1;Data Source = C:\Temp;"

That's all you need for free tables. If you still have problems, post back.

--
Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP
ci************* *@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden

Nov 21 '05 #3
I got the following to work:

Dim myConnection As New
System.Data.Ole Db.OleDbConnect ion("Provider=M icrosoft.Jet.OL EDB.4.0;Data
Source=C:\TEMP; Extended Properties=dBas e III")
Dim myCommand As New System.Data.Ole Db.OleDbCommand ("SELECT
OTHWAGE.* FROM OTHWAGE", myConnection)
myConnection.Op en()
Dim myReader As System.Data.Ole Db.OleDbDataRea der =
myCommand.Execu teReader()
While myReader.Read()
Debug.WriteLine (CStr(myReader. GetValue(0)))
End While
"Cindy Winegarden" wrote:
Hi Joe,

First off, try the FoxPro and Visual FoxPro OLE DB data provider, available


Nov 21 '05 #4
Hi Joe,

I'm glad you found a work-around.

--
Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP
ci************* *@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden
"genojoe" <ge*****@discus sions.microsoft .com> wrote in message
news:ED******** *************** ***********@mic rosoft.com...
I got the following to work:

Dim myConnection As New
System.Data.Ole Db.OleDbConnect ion("Provider=M icrosoft.Jet.OL EDB.4.0;Data
Source=C:\TEMP; Extended Properties=dBas e III")
Dim myCommand As New System.Data.Ole Db.OleDbCommand ("SELECT
OTHWAGE.* FROM OTHWAGE", myConnection)
myConnection.Op en()
Dim myReader As System.Data.Ole Db.OleDbDataRea der =
myCommand.Execu teReader()
While myReader.Read()
Debug.WriteLine (CStr(myReader. GetValue(0)))
End While
"Cindy Winegarden" wrote:
Hi Joe,

First off, try the FoxPro and Visual FoxPro OLE DB data provider,
available

Nov 21 '05 #5

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

Similar topics

5
714
by: PM | last post by:
Has anyone found a way to open a file exclusively where it will fail if the file is already open, i have tried the following _FileStream = new FileStream(@"C:\Data.txt", FileMode.Open, FileAccess.ReadWrite, FileShare.None); which does not prevent me from opening the file even if another user has the file open ie Notepad, it will prevent me from saving the file in notepad until i close the file in the app. I can then save changes made in...
1
4391
by: Alfons | last post by:
Hello, I have build a program that can do file transferring between a Windows XP computer and a DOS computer via a serial port. The Windows program I have build in C++ with Visual Studio 6.0. The DOS program I made in Turbo C++ 3.0. At this moment I am in a test phase of sending files and directories. The code I am using in DOS to open a file for writing looks like this (forgive me the typos, since I only have my source code at work...
14
11062
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a window.open function? I would prefer not to create a separate HTML page. So far all I have is the basic var cwin = window.open('images/KJV-THANKS.gif', 'Thanks', 'width=243,height=420,'); cwin.focus();
0
1536
by: John Winterbottom | last post by:
Does anyone know if this is possible? We are running Access XP with Windows XP Prof.. We have an ADP file we are using to print custom reports for a client. It's opened and conntrolled through automation, and we've had cases when the file was shut down unexpectedly and our normal disconnection code doesn't run. The next time the calling app tries to open the file, the connection dialog pops up. Users can't even click it away or enter a...
5
3313
by: Brad | last post by:
In several aspx applications I export crytal reports to pdf, xls and doc files and then the aspx page writes the selected export file to the client browser. This all works with one small quirk: When I run any of the web apps on my workstations iis website, the pdf download always produces the "File Download" dialog, even though I have Confirm after Download turned off. When I select to Open the file from this dialog the file opens in...
11
3585
by: aldrin | last post by:
I'm trying to run this code under windows xp sp2 using codeblocks v1.0 compiler with great difficulty.There is no problem with running this under KDevelop in linux. Any help would be greatly appreciated. Enter an interesting string. Too many cooks spoil the broth Error opening C:\myfile.txt for writing. Program termnated. This application has requested the Runtime to terminate it in an unusual way.
1
1947
by: gangs | last post by:
I need to know how can I open a file which is named using UTF-16 encoding in unicode. I am desperately trying to open the file using the wofstream typedef, but even it takes the parameter as const char*, I tried converting the filename from UTF16 to UTF8 encoding, wofstream does not seem to work with that. What I gather is that streams internally use fopen for opening up a file, I could not find any way for passing a file descriptor to the...
9
2305
compman9902
by: compman9902 | last post by:
Hello, and thank toy for reading this post. Thus far, this website has helped me a lot, (I have finally finished my encryptor: "site removed by moderator", go to the downloads link) and I will continue asking for help (so my rank may finally increase). Right now the topic at hand for me is opening file dialogs. Right now, the issue at hand is opening up a fully functional G.U.I. file prompt (both for opening and saving files please) that has...
15
2224
by: Umesh | last post by:
how to open a website like yahoo.com and use it as input? The following code doesn't work. #include"stdio.h" int main() { FILE *f; f=fopen("http://www.yahoo.com","r"); if(f==NULL)
34
5329
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File "<pyshell#10>", line 1, in <module> os.startfile("C:\Documents and Settings\Alex\My Documents\My
0
8432
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
8428
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...
1
8078
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6753
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...
1
5962
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5456
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3964
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1285
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.