Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB Connectivity » View Thread |
Messages 1 to 2 of 2 total |
Sharing ASP.net c# example |
Wed, Jul 8 2020 10:33 AM | Permanent Link |
Ivan Sine | I've been doing a little more with ASP and Elevate.ElevateDB.Data lately. And thought I'd post a little sample code. When editing a DevExpress aspxgridview, this code will execute a EDB procedure that inserts new or updates existing row.
using Elevate.ElevateDB.Data; . . . static public int ExecSP(string sqlText) { int result = 0; EDBConnection connection = new EDBConnection(ConfigurationManager.ConnectionStrings["EDB"].ConnectionString); using (connection) { connection.Open(); EDBCommand cmd = new EDBCommand(sqlText, connection); result = cmd.ExecuteNonQuery(); } return result; } protected void gridNext_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { int rowsupdated = ExecSP(String.Format("SCRIPT BEGIN CALL spMaxbid({0}, {1}, {2}); END", Convert.ToInt32(e.Keys["id"]), Convert.ToInt32(e.Keys["cid"]), Convert.ToDouble(e.NewValues["BidTo"]))); e.Cancel = true; (sender as ASPxGridView).CancelEdit(); } |
Wed, Aug 4 2021 7:14 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Ivan,
<< I've been doing a little more with ASP and Elevate.ElevateDB.Data lately. And thought I'd post a little sample code. When editing a DevExpress aspxgridview, this code will execute a EDB procedure that inserts new or updates existing row. >> Thanks for sharing. One small note to readers: you don't need to use a script in order to execute an EDB procedure, you can just set the EDBCommand.CommandType property to StoredProcedure (enumerated type): https://docs.microsoft.com/en-us/dotnet/api/system.data.commandtype?view=net-5.0 and then set the procedure name in the EDBCommand.CommandText property. However, this does cause the code to need more parameter handling, etc. so you've managed to do it with the lesser amount of code. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Wednesday, April 24, 2024 at 11:07 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |