Hi, I don't know what I'm doing wrong but every time I make a query and after the query I try to make an insert or an update to the bd it throws me the error: BeginTransaction error: database is locked. I try to close the resultset and the sql but I only get different errors. Please help
the code:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			the code:
			
				B4X:
			
		
		
		c= s.ExecQuery("SELECT * FROM shopy") ' WHERE cod = '" & cod & "' ORDER BY nombre ASC")
    If c.NextRow  Then
        If c.GetString("id_emp") = id_emp And c.GetString("id_sede") = sede Then
            c= s.ExecQuery("SELECT * FROM shopy_l WHERE id_prod = '" & lblprod.Text  & "'")
            If c.NextRow Then
                s.ExecNonQuery("UPDATE shopy_l Set cant=cant+1 WHERE id_prod = '" & lblprod.Text & "'")
            Else
                s.ExecNonQuery2("INSERT INTO shopy_l VALUES (?, ?, ?, ?, ?, ?, ?)", Array As String (0,lblprod.Text, lblnombrepedido.Text , lblprecio2.Text ,"1",txtnotas.Text,items))
            End If
            carshopy.Show
        Else 
            c.Close
            Msgbox2("Msg","Hay productos pendientes de otro restaurante o servicio, desea limpiar el carrito?", "Carrito de compras", Array ("Si", "No"))
            Wait For Msg_Click (ButtonText As String)
            If ButtonText = "Si" Then
                s.ExecNonQuery("DELETE FROM shopy_l")
                s.ExecNonQuery("DELETE FROM shopy")
                s.ExecNonQuery2("INSERT INTO shopy VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Array As String (0,id_emp, sede , miclase.id, lbldomicilio.Text,"","","","","",miclase.contrato & "/" & typeproducto,miclase.res_nom & "/" & miclase.res_dir,miclase.res_latlng & "/" & miclase.res_tiempo))
                s.ExecNonQuery2("INSERT INTO shopy_l VALUES (?, ?, ?, ?, ?, ?, ?)", Array As String (0,lblprod.Text, lblnombrepedido.Text , lblprecio2.Text ,"1",txtnotas.Text,items))
                carshopy.Show
'                    Activity.Finish
                End If
        End If
    Else
        'si no existe ps que ingrese nuevo y lance
        s.ExecNonQuery2("INSERT INTO shopy VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Array As String (0,id_emp, sede , miclase.id, lbldomicilio.Text,"","","","","",miclase.contrato & "/" & typeproducto,miclase.res_nom & "/" & miclase.res_dir,miclase.res_latlng & "/" & miclase.res_tiempo ))
        s.ExecNonQuery2("INSERT INTO shopy_l VALUES (?, ?, ?, ?, ?, ?, ?)", Array As String (0,lblprod.Text, lblnombrepedido.Text , lblprecio2.Text ,"1",txtnotas.Text,items))
        carshopy.Show
   
    End If
c.Close 
				 
			