Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 19th, 2007, 11:36 AM
javierotin javierotin is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 javierotin User rank is Corporal (100 - 500 Reputation Level)javierotin User rank is Corporal (100 - 500 Reputation Level)javierotin User rank is Corporal (100 - 500 Reputation Level)javierotin User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 29 m 51 sec
Reputation Power: 0
Excel interface, Asp and SQL Server

My older user interface was html's pages, now I use Ms Excel combined with Asp, and Asp with SQl Server.
The main concept is:
In the "save event" of Excel Sheet (VBA), I call a procedure that execute a batch file with Ms-Dos commands to Load the Excel's workbook in my website via FTP, in the same "sub", i execute "shell function" to run the asp page to make transactions with my database.
At the end I post the source code.

Mi antigua interface de usuario fueron paginas html, ahora uso Ms Excel combinado con Asp, y Asp con Sql Server.
El concepto principal es:
en el evento "guardar" de la planilla excel (VBA), llamo al procediminto que ejecuta un archivo batch con comandos de Ms-Dos para cargar el libro de Excel en mi sitio via FTP, en el mismo "sub", ejecuto la funcion "shell" para correr la pagina asp que hace las transacciones con la base de datos.
Al final posteo el codigo fuente.

Source code / codigo fuente:

Code:
'HERE I DECLARE AN API'S LIBRARIES TO DO SOME THINGS
'AQUI DECLARO LIBRERIAS API PARA HACER ALGUNAS COSAS.

'LIB TO MAKE DELAY INTERVALS OF EXECUTION
'LIB PARA HACER INTERVALOS RETARDO EN LA EJECUCION
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

'LIB TO FIND THE PATH OF A FILE, NECESARY TO KNOW WHERE IS IEXPLORE.EXE
'LIB PARA ENCONTRAR LA RUTA DE UN ARCHIVO, NECESARIA PARA SABER DONDE ESTA IEXPLORE.EXE
Private Declare Function apiSearchTreeForFile Lib "ImageHlp.dll" Alias _
        "SearchTreeForFile" (ByVal lpRoot As String, ByVal lpInPath _
        As String, ByVal lpOutPath As String) As Long

Function fSearchFile(ByVal strFilename As String, ByVal strSearchPath As String) As String
    
    'THIS FUNCTION FIND THE FILE
    'ESTA FUNCION ENCUENTRA EL ARCHIVO
    Dim lpBuffer As String
    Dim lngResult As Long
    fSearchFile = ""
    lpBuffer = String$(1024, 0)
    lngResult = apiSearchTreeForFile(strSearchPath, strFilename, lpBuffer)
    If lngResult <> 0 Then
        If InStr(lpBuffer, vbNullChar) > 0 Then
            fSearchFile = Left$(lpBuffer, InStr(lpBuffer, vbNullChar) - 1)
        End If
    End If
End Function

Sub SubirExcel()
    'THE PROCEDURE NAMED "SubirExcel" (tr. UploadExcel) MAKE THE JOB
    'EL PROCEDIMIENTO LLAMADO "SubirExcel", HACE EL TRABAJO.

    'FIRST, SAVE THE EXCEL BOOK.
    'PRIMERO, GUARDA EL LIBRO DE EXCEL.
    ActiveWorkbook.Save
    
    'SECOND, MAKE THE BATCH FILE WITH FTP COMANDS AND THE COMPLEMENTARY TEXT FILE WITH LOGIN INFO. ALL WITH FSO OBJECT.
    'SEGUNDO, CREA EL ARCHIVO BATCH CON LOS COMANDOS FTP Y EL ARCHIVO COMPLEMENTARIO DE TEXTO CON LA INFORMACION DE AUTENTICACION. TODO CON EL OBJECTO FSO.
    Dim ArchFtp
    Dim Carpeta
    Dim ArchLocal
    Dim ArchLocales
    Dim v_linea
    Dim v_cont

    Dim FSO As New FileSystemObject
    Dim FSO2 As New FileSystemObject
    Dim FSO3 As New FileSystemObject

   
    v_host = "(URL address blocked: See forum rules)"
    v_user = "myuser"
    v_pwd = "mypwd"
    v_mode = "binary" 'ascii/binary
    v_origen = "C:\"
    v_destino = "mydir/mysubdir/"
    v_archftpmain = v_origen & "\ftpmain.bat"
    v_archftplogin = v_origen & "\ftplogin.txt"
    v_excel = "comercialinvoice.xls"

    Set ArchFtpMain = FSO.OpenTextFile(v_archftpmain, 2, True)
    ArchFtpMain.WriteLine ("call ftp -s:" & v_archftplogin & " " & v_host)
    ArchFtpMain.Close
    Set ArchFtpMain = Nothing
    Set FSO = Nothing


    Set ArchFtp = FSO2.OpenTextFile(v_archftplogin, 2, True)
    Set Carpeta = FSO3.GetFolder(v_origen)
    Set ArchLocales = Carpeta.Files

    'THIRD, IF THE ACTIVE EXCEL SHEET IS "CLIENTS", I CHOOSE THE ASP PAGE "clients.asp" TO EXECUTE. THIS IS IMPORTANT, BECAUSE, THE ONLY THING TO DO THE USER IT'S CLICK THE BUTTON NAMED "SAVE" OR FILE MENU + SAVE.

    'TERCERO, SI LA PLANILLA ACTIVA DE EXCEL ES "CLIENTES", SELECCIONO LA PAGINA ASP "clients.asp" PARA EJECUTARLA. ESTO ES IMPORTANTE, PORQUE, LO UNICO QUE HACE EL USUARIO ES HACER CLIC EN EL BOTON LLAMADO "GUARDAR" O EN EL MENU ARCHIVO + GUARDAR.
    v_action = UCase(ActiveSheet.Name)
    Select Case v_action
        Case "CLIENTS", "CLIENTES"
            v_pagina = "clients.asp"
        Case "PRODUCTS", "PRODUCTOS"
            v_pagina = "products.asp"
        Case Else
            v_pagina = "invoice.asp"
    End Select


    ArchFtp.WriteLine (v_user)
    ArchFtp.WriteLine (v_pwd)
    ArchFtp.WriteLine ("cd httpdocs/" & v_destino)
    ArchFtp.WriteLine ("lcd " & v_origen)
    ArchFtp.WriteLine ("put " & v_excel)
    ArchFtp.WriteLine ("bye")
    ArchFtp.Close

    Set ArchLocal = Nothing
    Set ArchLocales = Nothing
    Set Carpeta = Nothing
    Set ArchFtp = Nothing
    Set FSO2 = Nothing
    Set FSO3 = Nothing
    
    xx = Shell(v_archftpmain, vbNormalFocus)
    
    'FOURTH, SEARCH THE PATH OF IEXPLORE.EXE.
    'CUARTO, BUSCO LA RUTA DE IEXPLORE.EXE
    v_iexplore = fSearchFile("iexplore.exe", "C:\")
    If v_pagina <> "" Then
        v_web = v_iexplore & " (URL address blocked: See forum rules)" & v_pagina
        Sleep (4000)

        'FINALLY, I EXECUTE THE WEB BROWSER IN HIDE MODE TO RUN THE ASP PAGE.
        'FINALMENTE, EJECUTO EL EXLORADOR WEB IN MODO OCULTO PARA CORRER LA PAGINA ASP.
        xx = Shell(v_web, vbHide)
    End If
            
End Sub



FEEL FREE TO USE THIS IDEA. BYE FRIENDS.
SIENTANSE EN LIBERTAD DE USAR ESTA IDEA. CHAO AMIGOS.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Excel interface, Asp and SQL Server


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway