Page 1 sur 1
import access

Publié:
01 Juil 2003 à 10:03
par titounella
J'aimerai savoir si quelqu'un connait la démarche pour importer une base access dans une base lotusj'aimerai en fait recuperer les données d'une table pour les mettres dans mon masqueMerci d'avance
Re: import access

Publié:
01 Juil 2003 à 10:28
par aer
Si tu veux tu adapter ça et ça devrait marcher sans problems. Il faut que tu exporte de ta base access des données vers excel bien formatées comme tu le souhaite et:Sub Initialize Dim workspace As New NotesUIWorkspace Dim session As New NotesSession Dim db As NotesDatabase Dim view As NotesView Dim doc As NotesDocument Dim docpere As NotesDocument Set db = session.CurrentDatabase Set doc = New NotesDocument(db) Dim collec As notesdocumentcollection Dim item As NotesItem Dim One As String Dim row As Integer Dim written, records,ver As Integer Dim FName As String Dim VName As String Dim xlFilename As String Dim temp As Variant ' File name temp = ( workspace.SaveFileDialog( False,"Sélectionnez le fichier à importer." ) ) xlFilename = Cstr (temp(0)) ' ' version ' Row number to import ans$ = Inputbox$("Utilisez-vous Word 2000 ? ","Info","Y") If ans$ = "n" Or ans$ = "N" Then ver= 8 Else ver=9 End If ' View name Set view = db.GetView("V_famille_simple") ' This is the default View name 'Next we connect to Excel and open the file. Then start pulling over the records. Dim Excel As Variant Dim xlWorkbook As Variant Dim xlSheet As Variant Print "Connecting to Excel..." If ver =9 Then Set Excel = CreateObject( "Excel.Application.9" ) ' for windows2000 Else Set Excel = CreateObject( "Excel.Application.8" ) ' for windows95 End If 'Excel.Visible = False ' Don't display the Excel window Print "Opening " & xlFilename & "..." Excel.Workbooks.Open xlFilename ' Open the Excel file Set xlWorkbook = Excel.ActiveWorkbook Set xlSheet = xlWorkbook.ActiveSheet ' Cycle through the rows of the Excel file, pulling the data over to Notes Goto Records Print "Disconnecting from Excel..." xlWorkbook.Close False 'Close the Excel file without saving (we made no changes) Excel.Quit 'Close Excel Set Excel = Nothing ' Free the memory that we'd used Print " " ' Clear the status line Records: row = 1 'These integers intialize à 1 car on ne prend pas en compte les titres des colonnes written = 0 Print "Starting import from Excel file..." Do While True Finish: With xlSheet row = row + 1 famille = .Cells( row, 1 ).Value doc.form = "Masque à utiliser" '...set values of doc... doc.nom_champs1 = .Cells( row, 2 ).Value doc.nom_champs2 = .Cells( row, 3 ).Value Call doc.Save( True, True ) 'Save the new doc written = written + 1 Print Str(written) If .Cells( row+1, 1 ).Value = "" Then Goto Done End With Loop Return Goto DoneError_call: Messagebox "Check Excel file location or SW Version or View Name or Form Name" ,MB_OK+MB_ICONINFORMATION,"Warning ! " Print " " ' Clear the status line Exit Sub Done: Excel.Quit 'Close Excel Set Excel = Nothing ' Free the memory that we'd used Msgbox "Importation terminée." Print "Imported " +Cstr(row) + " rows" ' Clear the status line End SubMa condition d'arret de l'import est : If .Cells( row+1, 1 ).Value = "" Then Goto Donesi la premiere case de la ligne suivante est vide alors je m'arrete.A toi d'adapter ce code.[%sig%]
Re: import access

Publié:
01 Juil 2003 à 10:42
par titounella
ok merci pour ces précisieuse indicationfaut avoir d'abord installer notesSql pour faire cela?
Re: import access

Publié:
01 Juil 2003 à 10:45
par Droad
La méthode la plus simple, c'est surement d'utiliser la fonction d'import native de Notes:- Exporte ta table en fichier Excel- Enregistre ton .xls en .wk3 ou .wk4- Créé une vue qui matche ton fichier d'import, avec dans chaque formule de colonne le nom du champ adéquat.- Ouvre cette vue et choisi Fichier\Importer, format Lotus 1-2-3- ... et laisse toi guider
Re: import access

Publié:
01 Juil 2003 à 10:52
par Raziel
Cette méthode marche tant que le traitement ne doit pas être automatisé...
Re: import access

Publié:
01 Juil 2003 à 15:45
par Marcello
Je fais la manip avec du code récuperé sur la sandboxSub Click(Source As Button)Dim session As New NotesSessionDim ws As New NotesUIWorkspaceDim db As NotesDatabaseDim view As NotesViewDim doc As NotesDocumentDim con As New ODBCConnectionDim qry As New ODBCQueryDim result As New ODBCResultSet REM Miscellaneous module variables Dim msg As String Dim FieldCount As Integer Dim Status As Integer REM MS Access Database declarationsConst adbFileName = "listepersonnel" ' This is the DSN Name as registered in ODBCConst adbTableName = "PERSONNEL" ' This is a table in the northwind database REM Notes Database declarationsConst ndbViewName = "vperso" ' This is an existing View in the target databaseConst ndbFormName = "Personnel" ' This is an existing Form in the target database REM Instantiate the major Notes objects Set db = session.CurrentDatabase Set view = db.GetView( ndbViewName ) REM Connect to the MS Access Database. Throw an error if it fails status = con.ConnectTo( adbFileName ) If Not con.IsConnected Then Messagebox "Could not connect to " & adbFileName & " database -- Did you register the ODBC Data Source???",, "Error" Exit Sub End If If con.GetError <> DBstsSUCCESS Then Messagebox con.GetExtendedErrorMessage,, "Connection Error - " & con.GetError & " " & con.GetErrorMessage Exit Sub End If Print "Connected to " & adbFileName & " database" ' Update the Notes Client Status Bar if we're okay REM If we got this far, we must be connected, so just for grins, let's show the user all the fields in this table.REM Note: "fields" has not been declared, so it will be a Variant Array -- that's what we want fields = con.ListFields( adbTableName ) msg = adbTableName & " contains the following fields:" & Chr(10) For FieldCount = Lbound( fields ) To Ubound( fields ) msg = msg & Chr(10) & fields( FieldCount ) NextREM Okay, let's display the Field List to the User... Messagebox msg,, "Fields from the " & adbFileName & " database" REM We made it this far, so let's setup the SQL Query. Throw an error if it fails Set qry.Connection = con Set result.Query = qry qry.SQL = "SELECT * FROM " & adbTableName ' Grab all of the fields (columns) from the specified table If qry.GetError <> DBstsSUCCESS Then Messagebox qry.GetExtendedErrorMessage,, "Query Error" & qry.GetError & " " & qry.GetErrorMessage Exit Sub End If REM Update the Notes Client Status Bar Print "Reading " & adbFileName & " database" ' Update the Notes Client Status Bar if we're okay REM Must be okay -- Get the Data result.Execute REM See if we have data. If so, loop through the ResultSet. If not, throw an error If result.IsResultSetAvailable Then Do result.NextRow REM Create a Notes Document, assign values, save the document. Do it until we're done. Set doc = db.CreateDocument ' Create a new Notes Document for this record doc.Form = ndbFormName REM Okay -- Let's get serious -- We'll use the MS Access Database field (Column) REM names for the field names in the Notes Documents doc.NomDemandeur = result.GetValue( "NP" ) doc.Responsable= result.GetValue( "RESP" ) doc.Matricule = result.GetValue( "MAT" ) Call doc.save( True, False ) Loop Until result.IsEndOfData REM We're done, so let's clean up the mess we've made and bail out result.Close( DB_CLOSE ) Print "Finished" ' Update the Notes Client Status Bar if we're okay Else REM If we got here, it means there was no data in the table, so throw an error (Informational) Messagebox "No data retrieved for " & adbTableName & " table", MB_ICONINFORMATION, "No data" Print "DOH!!!!! Got no data -- Bummer!!!!" ' Update the Notes Client Status Bar if we're NOT okay Exit Sub End If REM Give up the ODBC Connection like a good little boy con.Disconnect REM Update the view so the new documents will show up without having to press the F9 key Call view.Refresh Call ws.ViewRefresh End Sub