I am currently trying to get my Google Form to write directly to my SQL Server database when a form is submitted. I have successfully connected the form to the database using the script editor but it only writes to the database when I hard code the value. How do I read the input directly from the form and insert it into the database? My code is as follows:
function handleFormSubmit( event ) {
// var conn = Jdbc.getConnection(dbUrl, user, userPwd);
var conn =
Jdbc.getConnection("jdbc:sqlserver://dbname.database.windows.net:1433;" +
"databaseName=dbname;user=UN;password=PW;");
var stmt = conn.prepareStatement('INSERT INTO TemporaryTable '
+ '(FirstName, LastName) values (?, ?)');
//stmt.setString(1, 'Timestamp');
stmt.setString(1, event.namedValues['FirstName']);
stmt.setString(2, event.namedValues['LastName']);
stmt.execute();
}