I have a JDBC connection to MSSQL using GAS, the database I am using has class names and dates that are associated with the specific class.
I'm trying to retrieve all of the dates associated with the class Advanced Ventilator Skills Review . When I run the below code all I see in the log is the last date added to the database that is associated with the class above. Can anyone help me out? I want to get all of the dates associated with the class and what would be optimal is to display those dates in a drop down menu.
//Read from Database
function read(e) {
var app = UiApp.getActiveApplication();
var conn = Jdbc.getConnection("jdbc:sqlserver://IPAddress:1433;" +
"databaseName=databaseName;user=User;password=Password;");
var stmt = conn.createStatement();
var rs = stmt.executeQuery("SELECT * from dbo.tbl_ClassDetail WHERE className = 'Advanced Ventilator Skills Review'");
while(rs.next()) {
var class = rs.getString('className');
var date = rs.getString('classDate');
var time = rs.getString('classTime');
}
Logger.log(date);
rs.close();
stmt.close();
conn.close();
}
Using example from https://developers.google.com/apps-script/class_listbox , and in your show or UiApp - take the results array returned and add them in a for or while loop
var results = read(e);
for (i=0; i < results.length; i++) { lb.addItem [i][1];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.