Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12

Discussione: from Excel to Db

  1. #1

    from Excel to Db

    ciao,
    chi mi spiega i vari passi per portare dei dati da excel ad un Db.
    Praticamente io devo fare un file di Excel predisposto da me nel quale farò inserire dei dati. Poi dalla console devo leggere cella per cella e inserire i vari valori dentro al DB.

    spero in qualche suggerimento.

    ciao

  2. #2
    bhè un excel lo puoi leggere come un db , usi la stringa di connessione giusta (connectionstring.com)

    a sto punto quando lo hai letto non ti resta che scrivere dentro il tuo access con un ciclo di qualche tipo.

    Se legge questo topic _Jc ti potrebbe aiutare pechè mi pare che in qualche altro post parlava di lavori tipo questo
    Frate Priore: "È Lucifero in persona!"
    Trinità: "Lo conosci?"
    Bambino: "Mai sentito nominare, deve essere un professionista dell'est"

  3. #3
    bravo jc_ che si dimentica di mandare la roba a daniele..



    sono in ufficio...
    rimandami un altra mail dany.. sorry again

  4. #4

  5. #5
    senti visto che devo aspettare Jc_ intanto ho provato a cercare qualcosa in rete.

    ''You can also use the Excel ODBC driver I believe - didn''t try though
    Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=C:\exceltest.xls;" & _
    "Extended Properties=""Excel 8.0;"""

    ''You must use the $ after the object you reference in the spreadsheet
    Dim objreader As New OledbDataReader("SELECT * FROM [Sheet1$]", strConn)

    ora come scorro il file? al file excel devo assegnare dei nomi alle colonne..

    aiutooooooooooooo

  6. #6
    e aspetta che torno a casaaa. c'è tutto li dentro !

  7. #7
    codice:
    Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("prova.xls") & ";Extended Properties=Excel 8.0;"
    
    
            Dim oConn As OleDbConnection = New OleDbConnection
    
            oConn.ConnectionString = strConn
            oConn.Open()
    
            Dim oCmd As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM [Foglio1$]", oConn)
            Dim oDS As DataSet = New DataSet
            oCmd.Fill(oDS)
            Dim oRow As DataRow
            For Each oRow In oDS.Tables(0).Rows
                Response.Write("Row: " + oRow("cod_art").ToString() + "
    ")
            Next 
    
    
            If (oConn.State = ConnectionState.Open) Then
                oConn.Close()
            End If

    mi aiutate con il ciclo visto che c'è qualcosa che non va.

  8. #8
    invece che andare per nome colonna, non puoi usare l'indice ?

  9. #9
    senti non ho trovato molto materiale in giro, perciò se sai come fare mi fai vedere del codice cosi lo provo.

  10. #10
    ci sono riuscito anche se aspetto qualche dritta da Jc_

    codice:
    Dim oRow As DataRow
            For Each oRow In oDS.Tables(0).Rows
                Response.Write("Row: " + oRow(0).ToString() + "-")
                Response.Write("Row: " + oRow(1).ToString() + "-")
                Response.Write("Row: " + oRow(2).ToString() + "-")
                Response.Write("Row: " + oRow(3).ToString() + "-")
                Response.Write("Row: " + oRow(4).ToString() + "
    ")
            Next

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.