當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript mssql.Request類代碼示例

本文整理匯總了TypeScript中mssql.Request的典型用法代碼示例。如果您正苦於以下問題:TypeScript Request類的具體用法?TypeScript Request怎麽用?TypeScript Request使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Request類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

transaction2.begin(function(err) {
    // ... error checks

    let rolledBack = false;

    transaction2.on('rollback', function(aborted) {
        // emited with aborted === true

        rolledBack = true;
    });

    const request = new sql.Request(transaction2);
    request.query('insert into mytable (bitcolumn) values (2)', function(err, recordset) {
        // insert should fail because of invalid value

        if (err) {
            if (!rolledBack) {
                transaction2.rollback(function(err) {
                    // ... error checks
                });
            }
        } else {
            transaction2.commit(function(err) {
                // ... error checks
            });
        }
    });
});
開發者ID:typed-contrib,項目名稱:node-mssql,代碼行數:28,代碼來源:transaction.ts

示例2: function

var connection = new mssql.Connection (config, function (err)
	{
	var request = new mssql.Request(connection);

	request.query ('drop table cities');

	var command: string = 'create table cities (id varchar(10), name varchar(20),';
	command += ' population int, date_mod date)';

request.query (command, function (err, rows)
	{
	for (var key in dict_aa)
		{
console.log (key);
		var sql_str: string  = "insert into cities ";
		sql_str += "(id,name,population,date_mod) values (";

		var str_data: string = "'" + key + "','" + dict_aa[key].name;
		str_data += "'," + dict_aa[key].population;
		str_data += ",'" + dict_aa[key].date_mod + "')";

		sql_str += str_data;
			request.query (sql_str);
		}

	connection.close ();
	console.log ("*** 終了 ***");
	});
});
開發者ID:ekzemplaro,項目名稱:data_base_language,代碼行數:29,代碼來源:mssql_create.ts

示例3: Promise

 return new Promise((resolve,reject) => {
     let request = new sql.Request(this._transaction)
     request.query(script)
         .then(result => {
             resolve(result)
         })
         .catch(err => {
             reject(`Error in script ${err} - \n${script}`)
         })
 })
開發者ID:quick-tracks,項目名稱:quick-tracks-node-client,代碼行數:10,代碼來源:SqlServerAdapter.ts

示例4: function

const connection1 = new sql.Connection(config, function(err) {
    // ... error checks

    // Query

    const request = new sql.Request(connection1); // or: var request = connection1.request();
    request.query('select 1 as number', function(err, recordset) {
        // ... error checks

        console.dir(recordset);
    });

});
開發者ID:typed-contrib,項目名稱:node-mssql,代碼行數:13,代碼來源:multipleconnections.ts

示例5: mytable

transaction.begin(function(err) {
    // ... error checks

    var request = new sql.Request(transaction);
    request.query('insert into mytable (mycolumn) values (12345)', function(err, recordset) {
        // ... error checks

        transaction.commit(function(err) {
            // ... error checks

            console.log("Transaction committed.");
        });
    });
});
開發者ID:typed-contrib,項目名稱:node-mssql,代碼行數:14,代碼來源:transaction.ts

示例6: 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', () => { })
}
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:15,代碼來源:mssql-tests.ts

示例7: function

 var conn = new sql.Connection(config,function(err){
     if(err) {
         defer.reject(err);
     } else {
         var request = new sql.Request(conn);
         request.query(querystring, function(err,data) {
             if(err)
                 defer.reject(err);
             else
             {
                 defer.resolve(data);
             }
         })
     }
 });
開發者ID:ANNikolaev,項目名稱:episerver-node,代碼行數:15,代碼來源:db.ts

示例8: function

var connection = new mssql.Connection (config, function (err)
	{
	var request = new mssql.Request(connection);

	var command: string = sql_manipulate.delete_command_gen (id_in);

	request.query (command, function(err, rows)
		{
		if (err) throw err;

		console.log ("*** 終了 ***");
		});

	connection.close ();

});
開發者ID:ekzemplaro,項目名稱:data_base_language,代碼行數:16,代碼來源:mssql_delete.ts

示例9: 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) => { });
}
開發者ID:csrakowski,項目名稱:DefinitelyTyped,代碼行數:25,代碼來源:mssql-tests.ts

示例10: catch

        await server.connect().then(async pool => {

            context.log(`${context.bindingData.name}: Start Transaction.`);
            const transaction = new sql.Transaction(pool);
            await transaction.begin();

            try {
                for (let i = 0; i < parts.length; i++) {
                    const request = new sql.Request(transaction);
                    await request.query(`INSERT INTO pos_sales_tmp (${header4PosSalesTmp.join(',')}) VALUES ${parts[i].join(', ')};`);
                    context.log(`${context.bindingData.name}ファイル: ${i + 1}分割追加しました。`);
                }
                
                await transaction.commit(); 
            } catch (err) {
                await transaction.rollback();
                Logs.writeErrorLog(context, context.bindingData.name + '\\' + err.stack);
            }
        }).then(result => {
開發者ID:motionpicture,項目名稱:ttts-functions,代碼行數:19,代碼來源:pos_sales.ts


注:本文中的mssql.Request類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。