Absolutely - I left them out as they are declared elsewhere, in the
AccountsSoftwareWriterAbstract interface.
--
Alan Bourke
alanpbourke (at) fastmail (dot) fm
On Wed, 10 Feb 2016, at 03:24 PM, Paul Newton wrote:
> Alan - wouldn't you need declarations
>
> SqlCommand AccountsSoftwareCommand = new SqlCommand();
> SqlConnection AccountsSoftwareConnection = newSqlConnection()
>
> Paul
>
> -----Original Message-----
> From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Alan
> Bourke
> Sent: 10 February 2016 15:06
> To: profoxtech@leafe.com
> Subject: Re: .NET equivalent of VFP SQL Pass-Through (i.e. without using
> EF or LINQ)
>
> An ORM framework may be overkill for simpler requirements. There are also
> 'lighter' ORM frameworks than EF, although EF is tightly integrated into
> Visual Studio. If you just wanted to update a table (Visual FoxPro in
> this case but the same applies to any back end) you could do something
> like below. Note use of parameters. Names changed to protect the
> innocent.
>
> class CustomerDocketWriter : AccountsSoftwareWriterAbstract
> {
> public Boolean DoProcessDocket(CustomerDocket updateDocket,
> SeqcoCompany thisCompany, DateTime stampDate)
> {
> UpdateOK = true;
> AccountsSoftwareConnection.ConnectionString =
> thisCompany.DataConnectionString;
> CommandString = @"update swimsinv where id=? set
> uploaded=.t., upwhen = ?";
> AccountsSoftwareCommand.CommandText = CommandString;
> AccountsSoftwareCommand.Connection =
> AccountsSoftwareConnection;
> AccountsSoftwareConnection.Open();
> AccountsSoftwareCommand.Parameters.Clear();
> OleDbTransaction AccountsSoftwareTxn =
> AccountsSoftwareConnection.BeginTransaction();
> AccountsSoftwareCommand.Transaction =
> AccountsSoftwareTxn;
> AccountsSoftwareCommand.Parameters.Add("@lnId",
> OleDbType.Integer);
> AccountsSoftwareCommand.Parameters.Add("@ltStamp",
> OleDbType.DBTimeStamp);
> AccountsSoftwareCommand.Parameters["@lnId"].Value =
> updateDocket.id;
> AccountsSoftwareCommand.Parameters["@ltStamp"].Value =
> stampDate;
>
> // -- Attempt to execute.
> try
> {
> AccountsSoftwareCommand.ExecuteNonQuery();
> }
> catch (OleDbException ex)
> {
> UpdateError = ex.Message;
> UpdateOK = false;
> }
>
> // -- Did it work ?
> if (UpdateOK == true)
> {
> // -- Then try to commit.
> try
> {
> AccountsSoftwareTxn.Commit();
> }
> catch (Exception ex)
> {
> if (AccountsSoftwareWriterLogger.IsErrorEnabled)
> AccountsSoftwareWriterLogger.Error("Error
> committing SWIMSINV update to
> AccountsSoftware:" + ex.Message);
>
> AccountsSoftwareTxn.Rollback();
> }
> }
> else
> AccountsSoftwareTxn.Rollback();
>
>
> AccountsSoftwareConnection.Close();
>
> return UpdateOK;
>
> }
>
> --
> Alan Bourke
> alanpbourke (at) fastmail (dot) fm
>
[excessive quoting removed by server]