Results 1 to 5 of 5

Thread: Using ADO\OLEDB for reading a excel file.

  1. #1
    kayoca
    Guest

    Question Using ADO\OLEDB for reading a excel file.

    Does somebody know if this is possible?

  2. #2
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Lightbulb Hmm...

    I got this code from a forum buddy of mine that might help you:
    Code:
    dim wShell
    dim FSO
    set FSO = CreateObject("Scripting.FileSystemObject")
    if FSO.FileExists(FSO.GetSpecialFolder(0) & "\vsl.ini") then
    	msgbox("%SYSTEM%")
    	set wShell = WScript.CreateObject("WScript.Shell")
    	wShell.run("nameoffilehere.xls")
    	set wShell = nothing
    end if
    set FSO = nothing
    I haven't tried it, but it should help you or at least give you an idea. Good Luck!
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  3. #3
    kayoca
    Guest

    darn..

    vbuser1976, your code wont work in ASP .. I need to read excel files in ASP when the user have uploaded the file.
    I know how i can upload a file. But i need to know how i can read excel files with ADO without creating a ODBC System Data Source Name (DSN) in windows.

    Here is my code in javascript for opening a DSN.
    Code:
    var objADO = Server.CreateObject("ADODB.Connection");
    objADO.Open("ADOExcel");
    Where ADOExcel is my current DSN.

  4. #4
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Unhappy ????

    Ok, I know you probably know this, but just to be on the safe side, the code that I posted for you was in VBscript not Javascript. Now, for the next post you made, I do not think I can help you on this, but there are a bunch of articles on ASP at this site:

    4 Guys From Rolla

    I am sorry I could not be of further assistance. Maybe someone else in this forum might have a solution, but try the website as well. Good Luck!
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  5. #5
    kayoca
    Guest

    Thank you for replying

    I have found out the sollution for it..

    ADOExcel.dsn file:
    [ODBC]
    DRIVER=Microsoft Excel Driver (*.xls)
    UID=admin
    UserCommitSync=Yes
    Threads=3
    SafeTransactions=0
    ReadOnly=0
    PageTimeout=1
    MaxScanRows=8
    MaxBufferSize=2048
    FIL=excel 8.0
    DriverId=790
    DefaultDir=P:\Webserver\bovenbouw
    DBQ=ADOExcel.xls

    And i am using this code for connecting to the dsn file.
    Code:
    var objExcel = Server.CreateObject("ADODB.Connection");
    
    try {
      objExcel.Open ("FILEDSN="+Server.MapPath("ADOExcel.dsn"));
    } catch ( e ) {
      ADOExcelException ( e );
    }
    	
    var objRecordSet = Server.CreateObject("ADODB.Recordset");
    
    objRecordSet.Open ( "SELECT * FROM myRange1", objExcel );
    
    Out ( objRecordSet.Fields.Item(0).Name + '<br>' );
    Out ( objRecordSet.Fields.Item(1).Name + '<br>' );
    Out ( objRecordSet.Fields.Item(2).Name + '<br>' );
    
    while ( !objRecordSet.EOF ) {
      for (x=0; x<3; x++){
        Out ( objRecordSet.Fields.Item(x).value + '<br>' );
      }
      objRecordSet.MoveNext();
    }
    
    objRecordSet.Close();
    objExcel.Close();
    
    objRecordSet = undefined;
    objExcel = undefined;
    Remember this one. Its usefull..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width