Wiki Home

Ole Db Command


Namespace: SoftwareEng
From the .NET Framework Developer Center web site
OLEDBCOMMAND Class
Represents an SQL statement or stored procedure to execute against a data source.
Provides the following three methods to execute the command:
   EXECUTEREADER    Executes commands that return rows.
   EXECUTENONQUERY  Executes commands such as SQL INSERT, DELETE, UPDATE, and SET statements.
   EXECUTESCALAR    Retrieves a single value (for example, an aggregate value) from a database.

06/20/2007 - Steven Blake Here is a C# class that returns a VFP OLEDBCOMMAND object.
    using System;
    using System.IO;
    using System.Data.OleDb;

    public class VfpOle
    {
        string vfpOleProvider = "VFPOLEDB.1";
        string vfpDataSource;
        string vfpCollation;

        string vfpConnectionString
        {
            get
            {
                //  Compose OLE connection string to access Visual FoxPro
                string vfpConnstring =
                    "Provider=" + vfpOleProvider + ";" +
                    "Data Source=" + vfpDataSource + ";" +
                    "Mode=Share Deny None;" +
                    "Collating Sequence=" + vfpCollation + ";";
                return vfpConnstring;
            }
        }

        public OleDbCommand VfpCommand(string query, DirectoryInfo freeTableFolder)
        {
            //  For free standing FoxPro tables
            vfpDataSource = freeTableFolder.FullName;
            vfpCollation = "GENERAL";

            OleDbConnection vfpConnection = new OleDbConnection(vfpConnectionString);

            return new OleDbCommand(query, vfpConnection);
        }

        public OleDbCommand VfpCommand(string query, FileInfo dbcDatabase)
        {
            //  For access to a DBC container
            vfpDataSource = dbcDatabase.FullName;
            vfpCollation = "MACHINE";

            OleDbConnection vfpConnection = new OleDbConnection(vfpConnectionString);

            return new OleDbCommand(query, vfpConnection);
        }

    }

Category OOP Category Code Samples Category DotNet
( Topic last updated: 2007.06.20 04:41:54 PM )