There are a number of ways to accomplish the same thing. The most powerful
is probably to create a DataSet:
string connectionString =
"server=YourServer; uid=sa;
pwd=YourPassword; database=YourDB";
// get records from the the table
string commandString =
"Select foo, bar from myTable";
// create the data set command object
// and the DataSet
SqlDataAdapter dataAdapter =
new SqlDataAdapter(
commandString, connectionString);
DataSet dataSet = new DataSet();
// fill the data set object
dataAdapter.Fill(dataSet,"myTable");
--
Jesse Liberty
Liberty Associates, Inc.
.NET Training & Development
http://www.LibertyAssociates.com
"Burhan H. Afandi" <baf...@hotmail.com> wrote in message
news:OCqSOxWDBHA.1368@tkmsftngp04...
I am trying to access a dBase database file. I tried your code and
variations of it but it didn't work.
Thanks anyway
"Jesse Liberty" <jlib...@libertyassociates.com> wrote in message
news:e16537YDBHA.1416@tkmsftngp04...
Make sure you set the correct database, password, etc.
--
Jesse Liberty
Liberty Associates, Inc.
.NET Training & Development
http://www.LibertyAssociates.com
"Burhan H. Afandi" <baf...@hotmail.com> wrote in message
news:u#9GrdoDBHA.1772@tkmsftngp02...
I am still using Beta 1 of VS.NET, I guess my shipment got lost in the mail.
Anyway this is how I accessed the database using VB 6
Dim db As New adodb.Connection
db.CursorLocation = adUseServer
db.Open "PROVIDER=MSDASQL;driver=Microsoft dBase Driver
(*.dbf);server=c:\windows\desktop\;uid=;pwd=;database=myfolder"
Dim rs As New adodb.Recordset
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.ActiveConnection = db
rs.Open "select FNAME,LNAME,HPHONE,MPHONE from
c:\windows\desktop\myfolder\friends.dbf"
rs.MoveFirst
"Jesse Liberty" <jlib...@libertyassociates.com> wrote in message
news:OcfQOZrDBHA.1500@tkmsftngp02...
In other words, you can't use ODBC.
Is there a native OLE DB Provider for dBASE? Microsoft's web site mentions
one for FoxPro, which might work for you, but they don't mention where to
get it (other than buying Visual FoxPro).
There might also be a clunky way of getting to your data through Jet, since
Access can link to ODBC databases. That's not something I've done before, so
I can't even guess if it would work.
Article that says MSDASQL doesn't work:
http://msdn.microsoft.com/library/en-us/cpguidnf/html/cpconadonetproviders.a
sp?frame=true
Article that mentions Visual FoxPro OLE DB Provider:
http://msdn.microsoft.com/library/en-us/fox7help/html/dggrfOLEDBProviderforV
isualFoxPro.asp?frame=true
Nate
"Burhan H. Afandi" <baf...@hotmail.com> wrote in message
news:uMmDShsDBHA.1876@tkmsftngp07...
//dBase tables located in 'C:\Data\Common' is this example
OleDbConnection conn = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Data\\Common;Extended Properties=dBase IV;");
//a dBase file named Contact1.dbf is located in the dir specified above
OleDbCommand cmd = new OleDbCommand("SELECT * FROM CONTACT1", conn);
You can go from there.
--
Ryan Farley
Lead Application Developer
Customer FX Corporation
"Nathan Silva" <nat...@usa.net> wrote in message
news:u#S60n9DBHA.1616@tkmsftngp02...
http://www.microsoft.com/downloads/release.asp?ReleaseID=31125
But it won't work for Mr. Afandi because it requires .NET Framework SDK Beta
2.
Nate
"Ryan Farley" <ryan....@removethisnospam.customerfx.com> wrote in message
news:eNKKr$9DBHA.1400@tkmsftngp05...
Using the following code, I can read the database; I can even make changes
to it in the memory, but for whatever reason the database remains unchanged.
There are no errors reported, everything seems to work fine but when I check
the database to see if it has changed, everything looks untouched.
Here is the code:
//dBase tables located in 'C:\Data\Common' is this example
ADOConnection conn = new
ADOConnection("Provider=MSDASQL;DataSource=C:\\Data\\Common;driver=Microsoft
dBase Driver (*.dbf)");
//a dBase file named Contact1.dbf is located in the dir specified above
DataSet dataSet=new DataSet();
dataSet.Tables.Add( "Contact1");
ADODataSetCommand dsc=new ADODataSetCommand(@"SELECT * FROM
c:\data\Common\Contact1",conn);
dsc.FillDataSet(dataSet,"Contact1");
try
{
conn.Open();
for(int i=0;i<dataSet.Tables[0].Rows.Count;i++)
{
dataSet.Tables["
Contact1"].Rows[i][0]=(double)dataSet.Tables[0].Rows[i][0]/2;
}
dataSet.Tables[0].DataSet.Update(null);
dataSet.Tables[0].AcceptChanges();
}
catch(Exception e1)
{
System.WinForms.MessageBox.Show(e1.ToString());
}
finally
{
conn.Close();
}
"Ryan Farley" <ryan....@removethisnospam.customerfx.com> wrote in message
news:eNKKr$9DBHA.1400@tkmsftngp05...
Jamie
"Burhan H. Afandi" <baf...@hotmail.com> wrote in message
news:OQjC6PFEBHA.1268@tkmsftngp07...
"Jamie Macleod" <bubam...@yahoo.com> wrote in message
news:OAMSPgIEBHA.1348@tkmsftngp02...