Hello all!
Tried VFP solution and it's great! I just have some inquiries and concerns :
1. Does DBF with CDX working ? because DBF created with VFP9 with CDX getting corrupted
once I issued a replace command on a field. the corrupted DBF cant be open in VFP9 but I
open it on VFP5.
2. Any tuts links how to maniputate DBF files directly in C# using XSharp library.
Many thanks ^_^Y
VFP9 with CDX concerns ?
VFP9 with CDX concerns ?
Dexter,
We could really use some more info w.r.t. #1. Do you have example code ?
For #2: No tutorials yet
Robert
We could really use some more info w.r.t. #1. Do you have example code ?
For #2: No tutorials yet
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
VFP9 with CDX concerns ?
Hi Dexter,
What do you need? A WinForms application that can access DBF files?
Only read access or also write? Using a DataTable object is enough?
Wolfgang
P.S. my background is Clipper and VO, not VFP
I have some small sample applications that use DBF files from X# Core dialect.Any tuts links how to maniputate DBF files directly in C# using XSharp library.
What do you need? A WinForms application that can access DBF files?
Only read access or also write? Using a DataTable object is enough?
Wolfgang
P.S. my background is Clipper and VO, not VFP
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
VFP9 with CDX concerns ?
Inquiry 1 : Here's my test code
USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text
The Problem :
1, Using the above code accessing TESTDB.DBF "without" CDX it's ok
2. But if I put a CDX tag on DBF, it appended a blank records only
and did not replace the value both fields are still empty.
ex: INDEX ON DOC_TYPE+DOC_NO TAG DOC_NO
Inquiry 2 : XSharp in C#
I tried the following code inside C# and working correctly but that it I can't find the Replace command.
Thank you WriedMan+Robert ^_^y
Dex
USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text
Code: Select all
FUNCTION Start() AS VOID STRICT
SELECT 0
USE "C:TEMPTESTDB.DBF" SHARED
APPEND BLANK
*
Replace DOC_TYPE with "RR" ,;
DOC_NO with "12345"
WAIT "Press a key to exit ^_^"
RETURN
1, Using the above code accessing TESTDB.DBF "without" CDX it's ok
2. But if I put a CDX tag on DBF, it appended a blank records only
and did not replace the value both fields are still empty.
ex: INDEX ON DOC_TYPE+DOC_NO TAG DOC_NO
Inquiry 2 : XSharp in C#
I tried the following code inside C# and working correctly but that it I can't find the Replace command.
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using XSharp;
using XSharp.Core;
using XSharp.RT;
using XSharp.VFP;
using XDb = XSharp.CoreDb;
namespace WindowsFormsApp1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
XDb.SetSelect(1);
XDb.UseArea(true, "DBFVFP", @"C:TEMPTESTDB.DBF", "TESTDB", true, false);
XDb.Append(true);
}
}
}
Thank you WriedMan+Robert ^_^y
Dex
VFP9 with CDX concerns ?
Could you please send also the dbf and cdx files so we can reproduce the problem here? Thanks!
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
VFP9 with CDX concerns ?
Dexter,
Dex,
1) What happens if you close the file properly at the end of your code ?
2) To write values with the CoreDb layer you need to call FieldPut() with the column number and value.. Also don't forget to commit the changes and close the dbf.:
Robert
Dex,
1) What happens if you close the file properly at the end of your code ?
2) To write values with the CoreDb layer you need to call FieldPut() with the column number and value.. Also don't forget to commit the changes and close the dbf.:
Code: Select all
XDb.Commit()
XDb.CloseArea()
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
VFP9 with CDX concerns ?
Thanks Chris! The attached zipped file includes TestDb.DBF and TestDb.CDX
- Attachments
-
- TestDb_DBF_CDX.zip
- (434 Bytes) Downloaded 84 times
VFP9 with CDX concerns ?
Cool! I'll play with it more, many thanks Robert !
VFP9 with CDX concerns ?
YAY! Many thank's Robert the code below works like a charm even in share mode side by side with VFP9 and records with CDX also reflects in VFP9! ^_^y
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using XSharp;
using XSharp.Core;
using XSharp.RT;
using XSharp.VFP;
using XDb = XSharp.CoreDb;
namespace WindowsFormsApp1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
//--> Table work area
//
XDb.SetSelect(1);
//-> Open table in shared mode
//
if (! XDb.UseArea(true, "DBFVFP", @"C:TEMPTESTDB.DBF", "TESTDB", true, false) )
{
MessageBox.Show("Unable to open table TESTDB.DBF");
}
else
{
//--> Add blank record
//
XDb.Append(true);
//--> Update fields value
//
XDb.FieldPut(1, "DM"); // DOC_TYPE
XDb.FieldPut(2, "DM-12345"); // DOC_NO
//--> Write to disk
//
XDb.CommitAll();
//--> Close table
//
XDb.CloseArea();
}
}
}
}
- lumberjack
- Posts: 727
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
VFP9 with CDX concerns ?
Hi Dexter,
And the $1m effort to convert that to X#... :cheer:DexterZ wrote:YAY! Many thank's Robert the code below works like a charm even in share mode side by side with VFP9 and records with CDX also reflects in VFP9! ^_^y
Code: Select all
using System
using System.Collections.Generic
using System.Linq
using System.Threading.Tasks
using System.Windows.Forms
using XSharp.VFP
using XDb = XSharp.CoreDb
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread];
FUNCTION Start() AS VOID
//--> Table work area
XDb.SetSelect(1)
//-> Open table in shared mode
if ! XDb.UseArea(true, "DBFVFP", @"C:TEMPTESTDB.DBF", "TESTDB", true, false)
MessageBox.Show("Unable to open table TESTDB.DBF")
else
//--> Add blank record
XDb.Append(true)
//--> Update fields value
XDb.FieldPut(1, "DM"); // DOC_TYPE
XDb.FieldPut(2, "DM-12345"); // DOC_NO
//--> Write to disk
XDb.CommitAll()
//--> Close table
XDb.CloseArea()
endif
RETURN
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa