欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

asp獲取mysql大量數(shù)據(jù)報(bào)錯(cuò)

在使用ASP連接MySQL數(shù)據(jù)庫(kù)獲取大量數(shù)據(jù)時(shí),可能會(huì)遇到以下報(bào)錯(cuò)信息:

[MySQL][ODBC 5.3(a) Driver][mysqld-8.0.27]Commands out of sync; you can't run this command now

這是因?yàn)樵讷@取MySQL數(shù)據(jù)時(shí),ASP會(huì)將數(shù)據(jù)存儲(chǔ)在緩存中,當(dāng)數(shù)據(jù)量過(guò)大時(shí),緩存會(huì)被占滿,從而導(dǎo)致該錯(cuò)誤。

解決該問(wèn)題有如下兩種方法:

  1. 增加緩存大小
  2. Set conn = Server.CreateObject("ADODB.Connection")
    conn.ConnectionString = "DRIVER={MySQL ODBC 5.3 Driver}; SERVER=localhost; DATABASE=mydb; UID=myuser; PASSWORD=mypassword; OPTION=3"
    conn.Open
    conn.Execute "SET SESSION query_cache_size=268435456;"

    通過(guò)修改MySQL查詢緩存大小,可以增加緩存的空間,從而減少該錯(cuò)誤出現(xiàn)的概率。

  3. 使用多個(gè)連接獲取數(shù)據(jù)
  4. Function GetData()
    Dim conn, cmd, rs
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.ConnectionString = "DRIVER={MySQL ODBC 5.3 Driver}; SERVER=localhost; DATABASE=mydb; UID=myuser; PASSWORD=mypassword; OPTION=3"
    conn.Open
    Set cmd = Server.CreateObject("ADODB.Command")
    cmd.ActiveConnection = conn
    cmd.CommandText = "SELECT * FROM mytable"
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.CursorLocation = adUseServer
    rs.Open cmd, , adOpenForwardOnly, adLockReadOnly
    Do While Not rs.EOF
    '處理數(shù)據(jù)
    rs.MoveNext
    Loop
    rs.Close
    Set rs = Nothing
    Set cmd = Nothing
    conn.Close
    Set conn = Nothing
    End Function

    使用多個(gè)連接可以將數(shù)據(jù)分批獲取,從而減少緩存被占滿的情況出現(xiàn)。

上一篇mysql modeler
下一篇mysql monty