Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM ODBC Driver » View Thread |
Messages 1 to 2 of 2 total |
Insert Memo using Odbc in .NET |
Wed, May 12 2010 3:03 AM | Permanent Link |
Chris Holland SEC Solutions Ltd. 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 AM | Permanent 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] |
This web page was last updated on Tuesday, September 17, 2024 at 04:19 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |