结果始终为零

时间:2019-04-16 18:34:07

标签: asp-classic

在我的网络服务器上执行这段代码时,结果始终为 0 (ZERO)

任何人都可以对这个问题有个预感(解决方案更好:-D)

Dim MyTotalPages
Dim Recordset
Dim Connection
Dim aspDBcount
Dim ShowRowCount

ShowRowCount = 3 ' Fixed size

Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")

ConnString = "DRIVER={MySQL ODBC 5.3 Unicode Driver}; SERVER=server_address; UID=a_username;PASSWORD=a_password; OPTION=3; Port=a_port"

Connection.Open ConnString

SQL = "SELECT COUNT(*) AS MyRowCounts FROM `a_database`.`a_table`;"

Set Recordset = Connection.Execute(SQL)

aspDBcount = (Recordset("MyRowCounts") * 1) 

Recordset.Close

MyTotalPages = (aspDBcount * 1) / (ShowRowCount * 1))

Response.Write aspDBcount & "HTML_NEW_LINE" & ShowRowCount & "HTML_NEW_LINE" & MyTotalPages 
  
      
  • 输出为10、3、0
  •   
  • 应该是10、3、3.3333 ... ,数据库中有当前数据

1 个答案:

答案 0 :(得分:0)

使用:

dirEntry.entries = entries;
entries.forEach(entry => {...});

在MySQL中,aspDBcount = cInt(Recordset("MyRowCounts")) * 1 返回一个SELECT COUNT()整数类型,需要进行转换,然后才能对其进行操作并在VBScript中正确使用它。

BIGINT只能在CInt-32,767

之间转换数字

如果您的32,767超出了此范围,则需要使用SELECT COUNT()CLng-2,147,483,648的范围

您还可以使用2,147,483,647,这有点奇怪。它可以转换 HUGE 个数字,而且似乎没有溢出。如果您尝试传递一个非常大的整数,它将最终返回一个CDbl错误。

相关问题