I have been trying to set a PgSqlDataSource with an update command. Here is my scenario:
I am using a gridview from DevExpress which is loaded with data from 3 tables, such a grid represents a shopping cart. 2 of these tables are included only to get information about item's name, price and group it belongs to; the other table is the one that actually has the cart data.
I need to let the user change the number of items he or she wants to buy. The PgSqlDataSource is filled in code at run time (it depends on the session id) which means that it does not have any command in the editor's Select Text tab or in any other tab because I as mention above, it fills at run time. The field that needs to be updated (quantity) belongs to one of the 3 tables, the cart table.
When I run the web form and try to use the update button generated by the DevExpress gridview I get a message telling me that there is no update command defined and that is obvious.
This is the procedure that updates the cart every time an item is inserted or deleted; insertion and deletion are made in code too. At the end of this sub there are some controls that are updated to show total, discount and other.
Protected Sub ActualizaCarrito()
Try
Dim strQuery As String = ""
strQuery = strQuery + "SELECT "
strQuery = strQuery + "carrito.platillo as cve_platillo, "
strQuery = strQuery + "carrito.cantidad, "
strQuery = strQuery + "carrito.id_sesion, "
strQuery = strQuery + "carrito.comentario, "
strQuery = strQuery + "carrito.precio, "
strQuery = strQuery + "carrito.descto*carrito.precio/100 as descto, "
strQuery = strQuery + "carrito.precio - (carrito.descto*carrito.precio/100) as impte, "
strQuery = strQuery + "carrito.clave as cve_carrito, "
strQuery = strQuery + "menu.clave as cve_menu, "
strQuery = strQuery + "clasificacion.nombre || ' ' || menu.nombre as nbe_menu "
strQuery = strQuery + "FROM carrito, Menu, Clasificacion WHERE "
strQuery = strQuery + "carrito.platillo = menu.clave AND "
strQuery = strQuery + "Clasificacion.Clave = Menu.clasifica AND "
strQuery = strQuery + "carrito.id_sesion = '" + Session.SessionID.ToString + "'"
dsCarrito.SelectCommand = strQuery
Catch ex As Exception
Dim strMensaje As String = ""
strMensaje += "Se ha producido un error al actualizar el carrito de compras." + Chr(13) + Chr(10)
strMensaje += "Se ha enviado una notificación al administrador del sistema." + Chr(13) + Chr(10)
Utilerias.DespliegaMensaje(strMensaje, "", pnlPrincipal)
Utilerias.DespliegaMensaje(ex.Message + "\n \n" + ex.GetType().ToString + "\n \n", "", pnlPrincipal)
Utilerias.NuevoEvento("Default.aspx", "Public Sub ActualizaCarrito", ex.Message, ex.GetType.ToString, ex.StackTrace.ToString, Session("sesNbeSitio"))
End Try
Dim objCarrito As Carrito = New Carrito
objCarrito.AjaxSwitch = True
objCarrito.AjaxPanel = pnlPrincipal
objCarrito.Totales()
txtSubtotal.Text = FormatCurrency(objCarrito.Subtotal, 2)
txtDescuento.Text = FormatCurrency(objCarrito.TotalDescto, 2)
txtTotal.Text = FormatCurrency(CType(txtSubtotal.Text, Decimal) - CType(txtDescuento.Text, Decimal), 2)
End Sub
Is it possible to use the PgSqlDataSource editor to issue an update only?
I will appreciate very much your advice.
Respectfully,
Jorge Maldonado
PGSQLDATASOURCE UPDATE COMMAND ISSUE
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48