none
Copy data from MS Project to SQL database with VBA macro RRS feed

  • Pergunta

  • Hi,

    I need to create a VBA macro to copy some columns of MS Project (active project) and send / paste into a SQL Azure existing table. I have created the part of connection to the sql azure, I need a help now how could ride to another part of the code for example: Copy the column "cost", "status date", etc. And records in the SQL database table with the columns of the same names.

      Please someone help me?

    Sub ConnectionExample6()
    
       Dim cnn As ADODB.Connection
       Dim rs As ADODB.Recordset
    
       Set cnn = New ADODB.Connection
       
       
       ' Open a connection by referencing the ODBC driver.
       cnn.ConnectionString = "Driver={SQL Server Native Client 10.0};Server=tcp:xxxxxxxx.database.windows.net,1433;Database=xxxxxxxxo;Uid=xxxxxxxxx;Pwd={xxxxxxxxx};Encrypt=yes;Connection Timeout=30;"
       cnn.Open
    
    'Cria um Recordset usando uma instrução SQL
    
    Set rs = cnn.Execute("Select * FROM Projetos")
    
    ' Mostra o primeiro registro
    
    MsgBox rs("ProjectId")
    
    cnn.Close 'Fecha a conexão
    
    
    End Sub

    segunda-feira, 23 de março de 2015 14:43

Todas as Respostas