我有一些等待 SQL Server 记录写入操作的代码。但它并没有真正等待它。
围绕 SQL Server 记录写入的循环代码首先被执行。 然后我收到很多连接丢失错误。
async function nigel3()
{
var price1 = "";
var price2 = "";
var price3 = "";
var price4 = "";
var price5 = "";
var image = "";
var description = "";
var options1 = "";
var options2 = "";
var options3 = "";
var options4 = "";
var options5 = "";
var category = "";
var stocklevel1 = "";
var stocklevel2 = "";
var stocklevel3 = "";
var stocklevel4 = "";
var stocklevel5 = "";
var tax = "";
var itemswidth = 7 + 4;
var items = ["Resistors", "1k carbon film resistor.", "0.09", "0.09", "0.09", "0.09", "0.09", "10", "resistor1.png", "10", "10",
"Resistors", "2k metal film resistor ", "0.09", "0.09", "0.09", "0.09", "0.09", "10", "resistor1.png", "10", "10",
"Resistors", "3k 1watt resistor ", "0.09", "0.09", "0.09", "0.09", "0.09", "10", "noimageman.jpg", "10", "10",
"Resistors", "4k 1watt resistor ", "0.09", "0.09", "0.09", "0.09", "0.09", "10", "resistor1.png", "10", "10",
"Resistors", "5k 1watt resistor ", "0.09", "0.09", "0.09", "0.09", "0.09", "10", "noimageman.jpg", "10", "10",
"Resistors", "3k 1watt resistor ", "0.09", "0.09", "0.09", "0.09", "0.09", "10", "noimageman.jpg", "10", "10",
"Resistors", "4k 1watt resistor ", "0.09", "0.09", "0.09", "0.09", "0.09", "10", "resistor1.png", "10", "10",
"Resistors", "5k 1watt resistor ", "0.09", "0.09", "0.09", "0.09", "0.09", "10", "noimageman.jpg", "10", "10",
"USB_oscilloscope",
"PC usb digital storage oscilloscope X. Up to 1,000,000 samples per second. Good for about 20KHz sine wave." +
"Time bases are 250uS 1mS 5mS 10mS 50mS" +
"Voltage range is 250mV, 500mV, 1 , 5, 10, 20, 40 and 80 volts per division." +
"Positive trigger, negative trigger or no trigger." +
"Trigger level can be set using cursors keys." +
"Single shot display or roll multiple times display." +
"Measuring markers to measure voltage and time between two points." +
"Has an AC/DC switch. Comes with software on a CDROM." +
"Save/load traces. Print to printer function. Save trace to bitmap file." +
"It needs a x1 scope probe and printer A-B USB lead which are not included." +
"Powered by USB bus. Simple FFT display for displaying frequency content."
, "19.99", "0.09", "0.09", "0.09", "0.09", "10", "usb.jpg", "10", "",
"PCB_software",
"2018 Windows version of PCBCAD51 PCB DESIGN SOFTWARE with 127 LAYER AUTOROUTER. " +
"Runs on Windows XP (SP3) , Windows Vista and Windows 7, Windows 8 and Windows 10. " +
"This is a mature product with no bug list, if I find a bug it is fixed immediately. " +
"Support for this product is second to none, you are supported by the guy who wrote this software. " +
"Fully supported product sent by first class recorded post. " +
"Schematic and PCB symbol designer wizards. " +
"Auto creates SIL, DIL, circular and QUAD PCB footprints from your parameters. " +
"Schematic entry with auto convert schematic to PCB ratsnest, unconnected pin scanner and single ended net scanner. " +
"PCB entry with 127 layer rip up and retry auto-router with clearance and continuity check. " +
"Prints net names on tracks during editing. " +
"360 degree rotations of pcb components with obround pads. " +
"Integrity checker, compares schematic and PCB for differences. " +
"Component locater. Parts list output. " +
"Schematic/PCB component auto-renumbering and re-annotation. " +
"RS274X Gerber file generator and NC/Excellon drill file generator. " +
"Pick and place file generator with fiducial option. " +
"3D PCB viewer module. " +
"Output schematic to printer auto-sized.",
"20.00", "10", "0.09", "0.09", "0.09", "0.09", "cdrom.jpg", "10", "",
////////////////////////////////////////////
"lastentry", "Resistors", "20.00", "0.09", "0.09", "0.09", "0.09", "10", "usb.jpg", "10", ""];
var idptr = 1;
var ptr = 0;
while ((category = items[ptr * itemswidth]) != "lastentry")
{
description = items[ptr * itemswidth + 1];
price1 = items[ptr * itemswidth + 2];
price2 = items[ptr * itemswidth + 3];
price3 = items[ptr * itemswidth + 4];
price4 = items[ptr * itemswidth + 5];
price5 = items[ptr * itemswidth + 6];
stocklevel1 = 10;
stocklevel2 = 1;
stocklevel3 = 1;
stocklevel4 = 1;
stocklevel5 = 1;
image = items[ptr * itemswidth + 4 + 4];
tax = items[ptr * itemswidth + 5 + 4];
options1 = "1k";
options2 = "2k";
options3 = "3k";
options4 = "4k";
options5 = "5K";
await sql.query(
"INSERT INTO mvcnode_itemsforsale(Id,category,price1,price2,price3,price4,price5,description," +
"stocklevel1,stocklevel2,stocklevel3,stocklevel4,stocklevel5,tax,options1," +
"options2,options3,options4,options5,image)" +
" VALUES ('" +
idptr + "','" +
category + "','" +
price1 + "','" +
price2 + "','" +
price3 + "','" +
price4 + "','" +
price5 + "','" +
description + "','" +
stocklevel1 + "','" +
stocklevel2 + "','" +
stocklevel3 + "','" +
stocklevel4 + "','" +
stocklevel5 + "','" +
tax + "','" +
options1 + "','" +
options2 + "','" +
options3 + "','" +
options4 + "','" +
options5 + "','" +
image + "')"
, function (err, result) {
if (err)
console.log("resetitem insert error " + err + ' ' + category);
else
console.log("resetitem ok");
}
)
ptr++;
idptr++;
}
}
一年前的代码。
下载最新版本的Visual Studio后,显示错误
• Windows 11 - Microsoft Access - ODBC SQL Server Driver 17 - SQL Server 2016 - 仅在一个用户机器上触发错误
• 试图理解 async/await 和 Promise [重复]
• SQL Server:如何知道在排序表中,结果末尾有多少条记录等于最后一项
• 检查下一条记录的EMIDate是否小于或等于上一条记录的EMIDate,同时计算2个日期之间的差值
• 具有 SQL Server 后端的访问错误“此记录集不可更新”
• SQL Server 未从 Excel 工作簿导入所有数据
• AS608 带 Raspberry PI 的光学指纹传感器不等待手指输入
• Django 和 Telegram Bot - 保存功能触发但不保存更改