Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Sharing ASP.net c# example
Wed, Jul 8 2020 10:33 AMPermanent Link

Ivan Sine

Avatar

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 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email 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. Wink

Tim Young
Elevate Software
www.elevatesoft.com
Image