使用Node.Js

时间:2019-03-20 16:50:52

标签: sql node.js sql-server node-mssql

在过去的三周里,我一直在使用Node js和SQL Server进行数据库上的各种操作,但是当我尝试更新太多的列值(18列)却无法正常工作时,有人可以解释为什么发生了吗?

Node.Js代码:

new sql.Request(pool1).input('sellerId', sql.VarChar(100), postData.sellerId)
            .input('streetNum', sql.VarChar(45), postData.streetNum)
            .input('buildingNum', sql.VarChar(45), postData.buildingNum)
            .input('apartmentNum', sql.VarChar(45), postData.apartmentNum)
            .input('town', sql.VarChar(45), postData.town)
            .input('governance', sql.VarChar(45), postData.governance)
            .input('floorNum', sql.VarChar(45), postData.floorNum)
            .input('poBox', sql.VarChar(45), postData.poBox)
            .input('zipCode', sql.Int(), parseInt(postData.zipCode))
            .input('creditInfo', sql.VarChar(45), postData.creditInfo)
            .query('update Seller set street# = @streetNum, building#             =                @buildingNum, apartment# = @apartmentNum, town = @town, governance = @governance, floor# = @floorNum, PO_box = @poBox, zip_code = @zipCode, credit_info = @creditInfo where seller_id = @sellerId', (err, result1) => {
              if (!err) {
                console.log(result1.rowsAffected);
                res.json({
                  updateState: true,
                  resultt: result1.rowsAffected
                });
              } else {
                console.log(err);
                res.json({
                  updateState: false,
                  resultt: result.rowsAffected
                });
              }
            });

数据库DDL:

CREATE TABLE Seller(
seller_id varchar(100) not null,
seller_email  VARCHAR(45) not null unique,
brand_name  VARCHAR(45) NOT NULL unique,
first_name  VARCHAR(45) NOT NULL,
last_name  VARCHAR(45) NOT NULL,
password  VARCHAR(45) NOT NULL,
phone_number  VARCHAR(16) NOT NULL,
profile_image varchar(200)NULL,
street#  VARCHAR(45) NOT NULL,
building#  VARCHAR(45) NOT NULL,
apartment#  VARCHAR(45) NULL,
town  VARCHAR(45) not NULL,
governance  VARCHAR(45) NULL,
floor# VARCHAR(45) NULL,
PO_box VARCHAR(45) NULL,
zip_code int NOT NULL,
credit_info  VARCHAR(45) NOT NULL,
PRIMARY KEY (seller_id));

数据库DML:

insert into Seller(seller_id,seller_email,brand_name,first_name,last_name,password  
     ,phone_number,street#,building#,apartment#,town,governance,floor#  ,PO_box 
    ,zip_code,credit_info,profile_image)
    values('mosta.amer@gmail.com','.IDEA','Mostafa' ,'amer','12345678','0787375793','45p','2','2','moqabalain','Amman', '2' ,'amman/46','123456','visa','https://firebasestorage.googleapis.com/v0/b/         e-commerceasdasdasdasd-      c6abd.appspot.com/o/Products%2Fmosta.amer%40gmail.com%2Fic_launcher.png?alt=media&token=41a8db11-42d3-493a-874d-2ef74aba5b74')

0 个答案:

没有答案