本文整理匯總了TypeScript中mssql.PreparedStatement類的典型用法代碼示例。如果您正苦於以下問題:TypeScript PreparedStatement類的具體用法?TypeScript PreparedStatement怎麽用?TypeScript PreparedStatement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了PreparedStatement類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test_promise_returns
function test_promise_returns() {
// Methods return a promises if the callback is omitted.
var connection: sql.ConnectionPool = new sql.ConnectionPool(config);
connection.connect().then(() => { });
connection.close().then(() => { });
var preparedStatment = new sql.PreparedStatement(connection);
preparedStatment.prepare("SELECT @myValue").then(() => { });
preparedStatment.execute({ myValue: 1 }).then((recordSet) => { });
preparedStatment.unprepare().then(() => { });
var transaction = new sql.Transaction(connection);
transaction.begin().then(() => { });
transaction.commit().then(() => { });
transaction.rollback().then(() => { });
var request = new sql.Request();
request.batch('create procedure #temporary as select * from table').then((recordset) => { });
request.batch<Entity>('create procedure #temporary as select * from table;select 1 as value').then((recordset) => { });
request.bulk(new sql.Table("table_name")).then(() => { });
request.query('SELECT 1').then((recordset) => { });
request.query`SELECT ${1} as value`.then(res => { });
request.query<Entity>('SELECT 1 as value').then(res => { });
request.execute('procedure_name').then((recordset) => { });
}
示例2: test_classes_extend_eventemitter
function test_classes_extend_eventemitter() {
var connection: sql.ConnectionPool = new sql.ConnectionPool(config);
var transaction = new sql.Transaction();
var request = new sql.Request();
var preparedStatment = new sql.PreparedStatement();
connection.on('connect', () => { });
transaction.on('begin', () => { });
transaction.on('commit', () => { });
transaction.on('rollback', () => { });
request.on('done', () => { });
request.on('error', () => { });
preparedStatment.on('error', () => { })
}
示例3: function
ps5.prepare('select @param as value', function(err) {
// ... error checks
ps5.stream = true;
const request = ps5.execute({param: 12345}, function(err) {
ps5.unprepare(function(err) {
// ... error checks
});
});
request.on('recordset', function(columns) {
// Emitted once for each recordset in a query
});
request.on('row', function(row) {
// Emitted for each row in a recordset
});
request.on('error', function(err) {
// May be emitted multiple times
});
request.on('done', function(returnValue, affected) {
// Always emitted as the last one
console.log(affected); // Returns number of affected rows in case of INSERT, UPDATE or DELETE statement.
});
});