Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Insert Memo using Odbc in .NET
Wed, May 12 2010 3:03 AMPermanent Link

Chris Holland

SEC Solutions Ltd.

Avatar

Team Elevate Team Elevate

Hi Mike,

Something like this in C#

try
{
  using (OdbcCommand MyCommand = new OdbcCommand("",MyConnection))
  {
    string Sql = "";
    if (Exists == false)
      Sql = "INSERT INTO TableName (Title,Description) VALUES (?,?)";
    else
      Sql = "UPDATE TableName SET Title=?,Description=? WHERE Recno=?";

    MyCommand.CommandText = Sql;

    MyCommand.Parameters.Clear();
    MyCommand.Parameters.Add("Title", OdbcType.VarChar, 50);
    MyCommand.Parameters.Add("Description", OdbcType.Text);
    MyCommand.Parameters.Add("Recno", OdbcType.Int);

    MyCommand.Parameters["Title"].Value = Title;
    MyCommand.Parameters["Description"].Value = Description;
    MyCommand.Parameters["Recno"].Value = Recno;

    MyCommand.ExecuteNonQuery();
  }
}
catch (OdbcException OE)
{
  MessageBox.Show(OE.Message, "Error saving Description to disk",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

--
Chris Holland
[Team Elevate]
Wed, May 12 2010 10:43 AMPermanent Link

Mike

THANKS!!!!!!!!!!!!!!!!!

Chris Holland wrote:

Hi Mike,

Something like this in C#

try
{
  using (OdbcCommand MyCommand = new OdbcCommand("",MyConnection))
  {
    string Sql = "";
    if (Exists == false)
      Sql = "INSERT INTO TableName (Title,Description) VALUES (?,?)";
    else
      Sql = "UPDATE TableName SET Title=?,Description=? WHERE Recno=?";

    MyCommand.CommandText = Sql;

    MyCommand.Parameters.Clear();
    MyCommand.Parameters.Add("Title", OdbcType.VarChar, 50);
    MyCommand.Parameters.Add("Description", OdbcType.Text);
    MyCommand.Parameters.Add("Recno", OdbcType.Int);

    MyCommand.Parameters["Title"].Value = Title;
    MyCommand.Parameters["Description"].Value = Description;
    MyCommand.Parameters["Recno"].Value = Recno;

    MyCommand.ExecuteNonQuery();
  }
}
catch (OdbcException OE)
{
  MessageBox.Show(OE.Message, "Error saving Description to disk",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

--
Chris Holland
[Team Elevate]
Image