0

这对我来说是全新的,请多多包涵!

我有一种情况,我们在网站上有一个表单,它收集数据并将其发送到 Web 服务器上的 mySQL 表。该信息从网络服务器发送到 linux 机器上的 mySQL 表,我相信是通过 linux 机器上的某种导入脚本。

上周我们的 linux 服务器挂了,现在导入脚本无法正常工作。我有一个 import.txt 文件,我需要重新启动(我相信),但不知道该怎么做。

我在网上进行了研究,但我只看到有关 .sh 文件的信息。

谢谢!

如果有帮助,这是我需要运行的内容:

Public Sub ImportPubOrders()
Dim rsCopy1 As Recordset, rsCopy2 As Recordset, rsCopy3 As Recordset
Dim strSQL As String, strCriteria As String, strODBCdate As String
Dim lngFound As Long
On Error GoTo ErrorHandler

Set wrkODBC = CreateWorkspace("ODBCWorkSpace", "pubadmin", "Abo1prA5", dbUseODBC)
Set MySQLConn = wrkODBC.OpenConnection("ODBC;DSN=publications;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=publications;SERVER=10.116.11.2;UID=pubadmin;PASSWORD=Abo1prA5;PORT=3306;OPTION=3;STMT=;")
MySQLConn.QueryTimeout = 180

strODBCdate = Format(DateAdd("d", -1, Date), "yyyy-mm-dd")
'strODBCdate = "2009-03-11"

'Copy records from More.net PRO to DBSRVR
Set OAwrkODBC = CreateWorkspace("ODBCWorkSpace", "sslAGOmySQL", "k4-4js94nd", dbUseODBC)
Set OAMySQLConn = OAwrkODBC.OpenConnection("ODBC;DSN=OA_generalPRO;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=www_ago_mo_gov_ssl_data;SERVER=db.kinetic.more.net;UID=sslAGOmySQL;PASSWORD=k4-4js94nd;PORT=3306;OPTION=3;STMT=;")

strSQL = "LOCK TABLE orders_contacts READ, orders_ids READ, orders_items READ, orders_order READ"
OAMySQLConn.Execute (strSQL)

    'Check if there are orders to download
    strCriteria = "DATE_FORMAT(orders_order.order_date, '%Y-%m-%d') = " & Chr(34) & strODBCdate & Chr(34)
    strSQL = "SELECT form_id FROM orders_order WHERE " & strCriteria
    OAMySQLConn.Execute (strSQL)
    lngFound = OAMySQLConn.RecordsAffected

    'Orders have been submitted and need to be downloaded
    If lngFound >= 1 Then
        strSQL = "SELECT form_id, contact_id, DATE_FORMAT(order_date, '%Y-%m-%d %T') AS order_date FROM orders_order WHERE " & strCriteria
        Set rsCopy1 = OAMySQLConn.OpenRecordset(strSQL)
        Do While Not rsCopy1.EOF
            strSQL = "INSERT INTO orders_order (form_id, contact_id, order_date) " & _
                "VALUES (" & rsCopy1!form_id & ", " & rsCopy1!contact_id & ", " & Chr(34) & rsCopy1!order_date & Chr(34) & ")"
            MySQLConn.Execute (strSQL)
            rsCopy1.MoveNext
        Loop
        rsCopy1.Close

        strSQL = "SELECT item_id, orders_items.form_id, pub_name, quantity " & _
            "FROM orders_items INNER JOIN orders_order ON orders_items.form_id = orders_order.form_id " & _
            "WHERE " & strCriteria
        Set rsCopy2 = OAMySQLConn.OpenRecordset(strSQL)
        Do While Not rsCopy2.EOF
            strSQL = "INSERT INTO orders_items (item_id, form_id, pub_name, quantity) " & _
                "VALUES (" & rsCopy2!item_id & ", " & rsCopy2!form_id & ", " & Chr(34) & rsCopy2!pub_name & Chr(34) & ", " & rsCopy2!quantity & ")"
            MySQLConn.Execute (strSQL)
            rsCopy2.MoveNext
        Loop
        rsCopy2.Close

        strSQL = "SELECT orders_contacts.contact_id, orders_contacts.form_id, org_name, first_name, last_name, address1, address2, city, state, " & _
            "zip, email, phone, DATE_FORMAT(date_added, '%Y-%m-%d %T') AS date_added " & _
            "FROM orders_contacts INNER JOIN orders_order ON orders_contacts.contact_id = orders_order.contact_id " & _
            "WHERE " & strCriteria
        Set rsCopy3 = OAMySQLConn.OpenRecordset(strSQL)
        Do While Not rsCopy3.EOF
            strSQL = "INSERT INTO orders_contacts (contact_id, form_id, org_name, first_name, last_name, address1, " & _
                "address2, city, state, zip, email, phone, date_added) " & _
                "VALUES (" & rsCopy3!contact_id & ", " & rsCopy3!form_id & ", " & Chr(34) & rsCopy3!org_name & Chr(34) & _
                ", " & Chr(34) & rsCopy3!first_name & Chr(34) & ", " & Chr(34) & rsCopy3!last_name & Chr(34) & _
                ", " & Chr(34) & rsCopy3!address1 & Chr(34) & ", " & Chr(34) & rsCopy3!address2 & Chr(34) & _
                ", " & Chr(34) & rsCopy3!city & Chr(34) & ", " & Chr(34) & rsCopy3!state & Chr(34) & _
                ", " & Chr(34) & rsCopy3!zip & Chr(34) & ", " & Chr(34) & rsCopy3!email & Chr(34) & _
                ", " & Chr(34) & rsCopy3!phone & Chr(34) & ", " & Chr(34) & rsCopy3!date_added & Chr(34) & ")"
            MySQLConn.Execute (strSQL)
            rsCopy3.MoveNext
        Loop
        rsCopy3.Close

    Else
        DoCmd.Hourglass False
        Dim RS0 As Recordset
        Set RS0 = CurrentDb.OpenRecordset("log_Errors")
        RS0.AddNew
            RS0("error_loc") = "ZERO publication orders submitted online for " & strODBCdate
            RS0("error_time") = Now()
        RS0.Update
        RS0.Close
        Set RS0 = Nothing
    End If

strSQL = "UNLOCK TABLES"
OAMySQLConn.Execute (strSQL)

DoCmd.Hourglass False

Dim RS10 As Recordset
Set RS10 = CurrentDb.OpenRecordset("log_Errors")
RS10.AddNew
    RS10("error_loc") = "Import publications completed without error"
    RS10("error_time") = Now()
RS10.Update
RS10.Close
Set RS10 = Nothing

DoCmd.SetWarnings True
Exit Sub

ErrorHandler:
DoCmd.Hourglass False
    Dim RS2 As Recordset
    Set RS2 = CurrentDb.OpenRecordset("log_Errors")
    RS2.AddNew
        RS2("error_loc") = "procedure ImportPubOrders"
        RS2("error_num") = Err.Number
        RS2("error_desc") = Err.Description
        RS2("error_time") = Now()
    RS2.Update
    RS2.Close
    Set RS2 = Nothing

Set rsCopy1 = Nothing
Set rsCopy2 = Nothing
Set rsCopy3 = Nothing
DoCmd.SetWarnings True

结束子

4

2 回答 2

0

您将不得不使用第三方库,因为 linux 不支持 VBScript。您确定它具有 .txt 扩展名吗?如果是这样,这与 VBScript 有什么关系?

于 2012-06-05T14:41:04.123 回答
0

这是 Visual Basic。VBScript 不支持“On Error GoTo [label]”语句。

于 2014-08-13T16:19:15.530 回答