Import data from your DNN database into a Google Spreadsheet

Return to previous page

  • 4/7/2015
  • 668 Views

Comments

668 Views

Import data from your DNN database into a Google Spreadsheet

Last updated 3 years ago

Comments

Common

(Enter the content of this article below)

Advanced

 

Background

Google docs is a freeware web-based office suite offered by Google within its Google Drive service. It was formerly a storage service as well, but has since been replaced by Drive.4 It allows users to create and edit documents online while collaborating with other users live

In early March 2014, Google added "Addons" to their Google Docs platform. One of the addons in the initial launch of the store is a Email Merge by Mail Chimp addon. It's now possible to use a Google App Script that will connect to the DNN DB and grab your user database, that can then use the data against an add-on such as Mail chimp. The following script shows how to import data into a sheet and then do a mail merge with Mail Chimp.


function database_connection() {



var conn = Jdbc.getConnection("jdbc:sqlserver://IP-address:1433;" + "databaseName=DBName;user=username;password=password;");


var stmt = conn.createStatement();

stmt.setMaxRows(500);

var start = new Date();

var rs = stmt.executeQuery('select * from users');

var doc = SpreadsheetApp.getActiveSpreadsheet();

var cell = doc.getRange('a1');

var row = 0;

while (rs.next()) {

for (var col = 0; col < rs.getMetaData().getColumnCount(); col++) {

cell.offset(row, col).setValue(rs.getString(col + 1));

}

row++;

}

rs.close();

stmt.close();

conn.close();

var end = new Date();

Logger.log('Time elapsed: ' + (end.getTime() - start.getTime()));

}

  • thanks go to Dave Lalande who wrote the original forum post
Contents
No sections defined

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out