0

我正在我的计算机上进行编程,它运行良好——程序、数据库本身、插入数据库也运行良好。但是当我发布它并将程序安装在另一台计算机上时。它崩溃并且不执行 INSERT 命令。

这是我的代码。

Private Sub cmdBlank_Click(sender As System.Object, e As System.EventArgs) Handles cmdBlank.Click
strTariff1 = txtPart1.Text & " " & txtPName1.Text & " " & txtQty1.Text & " " & txtU1.Text
strTariff2 = txtPart2.Text & " " & txtPName2.Text & " " & txtQty2.Text & " " & txtU2.Text
strTariff3 = txtPart3.Text & " " & txtPName3.Text & " " & txtQty3.Text & " " & txtU3.Text
strTariff4 = txtPart4.Text & " " & txtPName4.Text & " " & txtQty4.Text & " " & txtU4.Text
'strTariff5 = txtPart5.Text & " " & txtPName5.Text & " " & txtQty5.Text & " " & txtU5.Text

Call saveToDb()
frmreportax.Show()
End Sub

Private Function saveToDb()
    conn.Close()

    Dim cmdAdd, cmdCount, cmdAdd2 As New iDB2Command
    Dim sqlAdd, sqlCount, sqlAdd2 As String
    Dim curr1, curr2, curr3, curr4 As String
    Dim count As Integer

    conn.ConnectionString = str
    conn.Open()

    'Check for duplicate entry
    sqlCount = "SELECT COUNT(*) AS count FROM cewe WHERE transport=@transport AND blnum=@blnum"

    With cmdCount
        .CommandText = sqlCount
        .Connection = conn

        .Parameters.AddWithValue("@transport", frmPart1.txtTransport.Text)
        .Parameters.AddWithValue("@blnum", frmPart1.txtNo.Text)
    End With

    count = Convert.ToInt32(cmdCount.ExecuteScalar())

    If count <> 0 Then
        MsgBox("Duplicate Entry: " & frmPart1.txtTransport.Text, vbOKOnly + vbExclamation)
    Else

        sqlAdd = "INSERT INTO cewe (page) " & _
                    "VALUES (@page) "

        With cmdAdd
            .Parameters.AddWithValue("@page", Val(frmPart1.txtPage.Text))
            .CommandText = sqlAdd
            .Connection = conn
            .ExecuteNonQuery()
        End With
    end if


    cmdAdd.Dispose()
    cmdAdd2.Dispose()
    conn.Close()
end function

请告诉我我做错了什么?当我在我的 PC 上运行并安装该程序时,它运行良好。但是当我在另一台 PC 上运行/安装它时,单击 cmdBlank 后它会崩溃。

4

2 回答 2

0

导致问题的原因可能有很多,但首先要查看的是任何错误日志或崩溃报告,它们可能会给出一些问题的迹象。尝试调试或记录以获得更好的画面。除此之外,还有一些小建议可能会有所帮助。

另一台计算机是否有权访问您指向的数据库?数据库连接是否指向本地主机?在这种情况下,您需要确保在新计算机上的数据库服务器上设置了相同的凭据(主机、用户名、密码、端口等)。新计算机上是否安装了数据库驱动程序?两台机器的根本区别是什么?

于 2014-09-30T04:30:04.933 回答
0

AS400 iSeries DB2 需要更新到版本 6.xx.0800 并进行了调整!

安装程序可以在这里找到 http://www-03.ibm.com/systems/power/software/i/access/windows_sp.html

问题解决了!

于 2014-09-30T07:15:23.707 回答