PGSQLDATASOURCE UPDATE COMMAND ISSUE

PGSQLDATASOURCE UPDATE COMMAND ISSUE

Postby JORGEMAL » Tue 22 Dec 2009 16:35

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
JORGEMAL
 
Posts: 164
Joined: Thu 03 Jul 2008 23:55

Postby StanislavK » Wed 23 Dec 2009 13:00

Could you please provide us with a small test project or specify the exact way to generate DataSet you are using?
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby JORGEMAL » Thu 24 Dec 2009 16:18

StanislavK wrote:Could you please provide us with a small test project or specify the exact way to generate DataSet you are using?


I appreciate your reply. I have solved this situation directly in my code without using the datasource update process.

Respectfully,
Jorge Maldonado
JORGEMAL
 
Posts: 164
Joined: Thu 03 Jul 2008 23:55


Return to dotConnect for PostgreSQL