• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript mssql.VarChar函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中mssql.VarChar函数的典型用法代码示例。如果您正苦于以下问题:TypeScript VarChar函数的具体用法?TypeScript VarChar怎么用?TypeScript VarChar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了VarChar函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1:

    .then(function() {
        const value = 50;
        
        // Query

        new sql.Request()
            .input('input_parameter', sql.Int, value)
            .query('select * from mytable where id = @input_parameter').then(function(recordset) {
                console.dir(recordset);
            }).catch(function(err) {
                // ... error checks
            });

        // Stored Procedure

        new sql.Request()
            .input('input_parameter', sql.Int, value)
            .output('output_parameter', sql.VarChar(50))
            .execute('procedure_name')
            .then(function(recordsets) {
                console.dir(recordsets);
            })
            .catch(function(err) {
                // ... error checks
            });
    })
开发者ID:typed-contrib,项目名称:node-mssql,代码行数:26,代码来源:promises.ts


示例2: test_table

function test_table() {
    var table = new sql.Table('#temp_table');

    table.create = true;

    table.columns.add('name', sql.VarChar(sql.MAX), { nullable: false });
    table.columns.add('type', sql.Int, { nullable: false });
    table.columns.add('amount', sql.Decimal(7, 2), { nullable: false });

    table.rows.add('name', 42, 3.50);
    table.rows.add('name2', 7, 3.14);
}
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:12,代码来源:mssql-tests.ts


示例3: function

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

    // Stored Procedure

    const request = connection2.request();
    request.input('input_parameter', sql.Int, 10);
    request.output('output_parameter', sql.VarChar(50));
    request.execute('procedure_name', function(err, recordsets, returnValue) {
        // ... error checks

        console.dir(recordsets);
    });
});
开发者ID:typed-contrib,项目名称:node-mssql,代码行数:14,代码来源:multipleconnections.ts


示例4: function

sql.connect(config, function(err) {
    // ... error checks

    // Query

    new sql.Request().query('select 1 as number', function(err, recordset) {
        // ... error checks

        console.dir(recordset);
    });

    // Stored Procedure

    new sql.Request()
    .input('input_parameter', sql.Int, value)
    .output('output_parameter', sql.VarChar(50))
    .execute('procedure_name', function(err, recordsets, returnValue) {
        // ... error checks

        console.dir(recordsets);
    });
});
开发者ID:typed-contrib,项目名称:node-mssql,代码行数:22,代码来源:nestedcallbacks.ts


示例5: function

var connection: sql.ConnectionPool = new sql.ConnectionPool(config, function (err: any) {
    if (err != null) {
        console.warn("Issue with connecting to SQL Server!");
    }
    else {
        connection.query`SELECT ${1} as value`.then(res => { });
        var requestQuery = new sql.Request(connection);

        var getArticlesQuery = "SELECT * FROM TABLE";

        requestQuery.query(getArticlesQuery, function (err, result) {
            if (err) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);
            }
            // checking to see if the articles returned as at least one.
            else if (result.recordset.length > 0) {
            }
        });

        getArticlesQuery = "SELECT 1 as value FROM TABLE";

        requestQuery.query<Entity>(getArticlesQuery, function (err, result) {
            if (err) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);

            }
            // checking to see if the articles returned as at least one.
            else if (result.recordset.length > 0 && result.recordset[0].value) {
            }
        });

        var requestStoredProcedure = new sql.Request(connection);
        var testId: number = 0;
        var testString: string = 'test';

        requestStoredProcedure.input('pId', testId);
        requestStoredProcedure.input('pString', testString);


        requestStoredProcedure.execute('StoredProcedureName', function (err, recordsets, returnValue) {
            if (err != null) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);
            }
            else {
                console.info(returnValue);
            }
        });

        requestStoredProcedure.execute<Entity>('StoredProcedureName', function (err, recordsets, returnValue) {
            if (err != null) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);
            }
            else {
                console.info(returnValue);
            }
        });

        var requestStoredProcedureWithOutput = new sql.Request(connection);
        var testId: number = 0;
        var testString: string = 'test';

        requestStoredProcedureWithOutput.input("name", sql.VarChar, "abc");               // varchar(3)
        requestStoredProcedureWithOutput.input("name", sql.VarChar(50), "abc");           // varchar(MAX)
        requestStoredProcedureWithOutput.output("name", sql.VarChar);                     // varchar(8000)
        requestStoredProcedureWithOutput.output("name", sql.VarChar, "abc");              // varchar(3)

        requestStoredProcedureWithOutput.input("name", sql.Decimal, 155.33);              // decimal(18, 0)
        requestStoredProcedureWithOutput.input("name", sql.Decimal(10), 155.33);          // decimal(10, 0)
        requestStoredProcedureWithOutput.input("name", sql.Decimal(10, 2), 155.33);       // decimal(10, 2)

        requestStoredProcedureWithOutput.input("name", sql.DateTime2, new Date());        // datetime2(7)
        requestStoredProcedureWithOutput.input("name", sql.DateTime2(5), new Date());     // datetime2(5)

        requestStoredProcedure.execute('StoredProcedureName', function (err, recordsets, returnValue) {
            if (err != null) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);
            }
            else {
                console.info(requestStoredProcedureWithOutput.parameters['output'].value);
            }
        });

        requestStoredProcedure.execute<Entity>('StoredProcedureName', function (err, recordsets, returnValue) {
            if (err != null) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);
            }
            else {
                console.info(requestStoredProcedureWithOutput.parameters['output'].value);
            }
        });
    }
});
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:92,代码来源:mssql-tests.ts


示例6: varchar

/** Samples from https://github.com/patriksimek/node-mssql#data-types */

import * as sql from "mssql";

const request = new sql.Request();

request.input("name", sql.VarChar, "abc");               // varchar(3)
request.input("name", sql.VarChar(50), "abc");           // varchar(50)
request.input("name", sql.VarChar(sql.MAX), "abc");      // varchar(MAX)
request.output("name", sql.VarChar);                     // varchar(8000)
request.output("name", sql.VarChar, "abc");              // varchar(3)

request.input("name", sql.Decimal, 155.33);              // decimal(18, 0)
request.input("name", sql.Decimal(10), 155.33);          // decimal(10, 0)
request.input("name", sql.Decimal(10, 2), 155.33);       // decimal(10, 2)

request.input("name", sql.DateTime2, new Date());        // datetime2(7)
request.input("name", sql.DateTime2(5), new Date());     // datetime2(5)
开发者ID:typed-contrib,项目名称:node-mssql,代码行数:18,代码来源:datatypes.ts


示例7: function

/** Samples from https://github.com/patriksimek/node-mssql#table-valued-parameter-tvp */

import * as sql from "mssql";

const tvp = new sql.Table()

// Columns must correspond with type we have created in database.
tvp.columns.add('a', sql.VarChar(50));
tvp.columns.add('b', sql.Int);

// Add rows
tvp.rows.add('hello tvp', 777); // Values are in same order as columns.

// You can send table as a parameter to stored procedure.
const request = new sql.Request();
request.input('tvp', tvp);
request.execute('MyCustomStoredProcedure', function(err, recordsets, returnValue) {
    // ... error checks

    console.dir(recordsets[0][0]); // {a: 'hello tvp', b: 777}
});
开发者ID:typed-contrib,项目名称:node-mssql,代码行数:21,代码来源:tvp.ts


示例8: function

request.input('input_parameter', value);
request.input('input_parameter', sql.Int, value);

class MyClass {
    number: number;
}
sql.map.register(MyClass, sql.Text);

sql.map.register(Number, sql.BigInt);

/**
 * output https://github.com/patriksimek/node-mssql#output-name-type-value
 */

request.output('output_parameter', sql.Int);
request.output('output_parameter', sql.VarChar(50), 'abc');

/**
 * pipe https://github.com/patriksimek/node-mssql#pipe-stream
 */

const request1 = new sql.Request();
let stream: NodeJS.WritableStream;
request1.pipe(stream);
request1.query('select * from mytable');
stream.on('error', function(err) {
    // ...
});
stream.on('finish', function() {
    // ...
});
开发者ID:typed-contrib,项目名称:node-mssql,代码行数:31,代码来源:request.ts


示例9: function

    ps.execute({param: 12345}, function(err, recordset) {
        // ... error checks

        ps.unprepare(function(err) {
            // ... error checks

        });
    });
});

/**
 * input https://github.com/patriksimek/node-mssql#input-name-type
 */

ps.input('input_parameter', sql.Int);
ps.input('input_parameter', sql.VarChar(50));

/**
 * output https://github.com/patriksimek/node-mssql#output-name-type
 */

ps.output('output_parameter', sql.Int);
ps.output('output_parameter', sql.VarChar(50));

/**
 * prepare https://github.com/patriksimek/node-mssql#prepare-statement-callback
 */

const ps2 = new sql.PreparedStatement();
ps2.prepare('select @param as value', function(err) {
    // ... error checks
开发者ID:typed-contrib,项目名称:node-mssql,代码行数:31,代码来源:preparedstatement.ts



注:本文中的mssql.VarChar函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript mssql.connect函数代码示例发布时间:2022-05-25
下一篇:
TypeScript mssql.Decimal函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap