我试图从Excel工作表中运行查询。下面是我的代码,但是我想我在这里找不到东西。我认为我的问题是SQL代码。有帮助吗?
谢谢
Baha
Option Explicit
Const TARGET_DB1 = "DB_PlayerMasterManual.mdb"
Const CopyTarget_DB1 = "DB_PlayerMasterManualBackUp.mdb"
Sub DisplayRatings1()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim fld As ADODB.Field
Dim MyConn
Dim i As Long
Dim lastrow As Long
Dim cel As Range
lastrow = Sheets("RatingReport").Range("A1048576").End(xlUp).Row
Dim ShDest As Worksheet
Set ShDest = Sheets("RatingReport")
Set cnn = New ADODB.Connection
MyConn = "J:\Gaming Common\PlayerMaster_Manual" & "\" & _
"DataFiles\" & TARGET_DB1
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open MyConn
End With
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseServer
rst.Open "Select CustName & _
FROM tblRating WHERE CustID='" & _
CustIdTB.Value & "' ", cnn, , , adCmdTable
ShDest.Activate
Range("A1").CurrentRegion.Offset(1, 0).Clear
i = 0
With Range("A1")
For Each fld In rst.Fields
.Offset(0, i).Value = fld.Name
i = i + 1
Next fld
End With
Range("A2").CopyFromRecordset rst
rst.Close
cnn.Close
End Sub
答案 0 :(得分:0)
您似乎没有在任何地方定义// MakeBaseBoard.js
// named export - genGuiBoard
var genGuiBaseBoard = function(lastRow, lastCol, gameBoardWidth, gameBoardHeight) {
// make base elements and attributes
var boardTiles = document.getElementById("board");
var tile = document.createElementNS("http://www.w3.org/2000/svg", "svg");
var squareElem = document.createElementNS("http://www.w3.org/2000/svg", "rect");
var textElem = document.createElementNS("http://www.w3.org/2000/svg", "text");
// define square with and set loop values to 0
var width = 20;
var height = width;
var row = 0;
var col = 0;
var xcord = 0;
var ycord = 0;
// text element coords
var textXcord = 6;
var textYcord = 15;
// board
tile.setAttribute("width", `${gameBoardWidth}`);
tile.setAttribute("height", `${gameBoardHeight}`);
tile.setAttribute("id", "gameBoard");
boardTiles.appendChild(tile);
// row
for (row = 0; row < lastRow; row++) {
// col
for (col = 0; col < lastCol; col++) {
// rect
var squareElem = document.createElementNS("http://www.w3.org/2000/svg", "rect");
squareElem.setAttribute("class", "game-squares");
squareElem.setAttribute("data-rowIndex", `${row}`)
squareElem.setAttribute("data-colIndex", `${col}`)
squareElem.setAttribute("id", `row${row}col${col}`);
squareElem.setAttribute("width", `${width}px`);
squareElem.setAttribute("height", `${height}px`);
squareElem.setAttribute("x", `${xcord}`);
squareElem.setAttribute("y", `${ycord}`);
squareElem.setAttribute("stroke", "black");
squareElem.setAttribute("stroke-width", "1");
squareElem.setAttribute("stroke-opacity", "0.7");
squareElem.setAttribute("fill", "#b1bcce");
squareElem.setAttribute("fill-opacity", "0.5");
tile.appendChild(squareElem);
// generate text elements with base style but wait to add Bombs
var textElem = document.createElementNS("http://www.w3.org/2000/svg", "text");
textElem.setAttribute("class", `text-squares`);
textElem.setAttribute("data-rowIndex", `${row}`)
textElem.setAttribute("data-colIndex", `${col}`)
textElem.setAttribute("id", `text-id-row${row}col${col}`);
textElem.setAttribute("x", `${textXcord}`);
textElem.setAttribute("y", `${textYcord}`);
textElem.setAttribute("font-size", "1.0em");
// text elements are placed invisibily and event handles are laid later
textElem.setAttribute("fill-opacity", "0.0");
textElem.innerHTML = `#`;
tile.appendChild(textElem);
// looping vars
xcord+=width;
textXcord+=width;
}
// reset x
xcord=0;
textXcord=6;
// continue y
ycord+=width;
textYcord+=width;
}
}
export { genGuiBaseBoard };
。我想这是数据库的文件名。也许这是故意的,或者可能是一个错误。如果有错误,请更正。假设这是一个全局或函数,则在3行的查询中您也会遇到一个小问题:
尝试更改:
TARGET_DB1
收件人:
rst.Open "Select CustName & _
FROM tblRating WHERE CustID='" & _
CustIdTB.Value & "' ", cnn, , , adCmdTable
UDPATE:
根据评论,尝试:
rst.Open "Select CustName " & _
"FROM tblRating WHERE CustID='" & _
CustIdTB.Value & "' ", cnn, , , adCmdTable