Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to zap or pack a DBF in ASP net
Message
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
01132137
Message ID:
01132340
Views:
13
That looks a bit busy in c# code. I have used vfp a long time but delving in VB net and vfpoledb. I have sqldatasource setups in VS.net so I was looking toward that angle. But Perry does have a point about exclusive use. I guess I'm looking for a way to use temp files to get this accomplished, just need a few logic ideas.

>Timothy,
>
>In VFP open a database containing a table you want to pack or zap. Type in the Command Window:
>
>MODIFY PROCEDURE
>
>In opening window type the following (suppose there's ACCOUNTS table in the database):
>
>PROCEDURE sp_ZapAccounts
>	USE accounts EXCLUSIVE
>	ZAP
>
>PROCEDURE sp_PackAccounts
>	USE accounts EXCLUSIVE
>	PACK
>
>Save and close. Also close the database. Note that both PACKing and ZAPping require exclusive access to tables.
>
>Create console C# project (conversion to VB.Net is obvious). Add the following code. Replace Data Source parameter in ConnStr with actual value, the path to your database. If you use VB.Net replace all "\\" with "\".
>
>using System;
>using System.Data;
>using System.Data.OleDb;
>
>namespace AccessingVFPviaOleDb
>{
>	class Class1
>	{
>		[STAThread]
>		static void Main(string[] args)
>		{
>			ZapAccounts();
>		}
>
>		static void ZapAccounts()
>		{
>			string ConnStr = "Provider=vfpoledb.1;" +
>					"Data Source=C:\\MYDATA\\TEST.DBC;" +
>					"Collating Sequence=machine";
>
>			OleDbConnection cn = new OleDbConnection(ConnStr);
>
>			try
>			{
>				cn.Open();
>				OleDbCommand cmd = new OleDbCommand("sp_ZapAccounts()", cn);
>				cmd.ExecuteNonQuery();
>			}
>			catch (Exception e)
>			{
>				Console.Write(e.Message);
>				return;
>			}
>			finally
>			{
>				cn.Close();
>			}
>		}
>	}
>}
>
>As you can see, the code creates a OleDb connection to the database and executes a single SQL statement, which is the name of a stored procedure (don't forget to put round brackets).
>
>Hope it helps.
"Build a man a fire, and he's warm for a day.
Set a man on fire, and he's warm for the rest of his life."
Previous
Reply
Map
View

Click here to load this message in the networking platform