내 컴퓨터에서 프로그래밍을 수행하고 있는데 데이터베이스에 삽입하는 프로그램 자체가 정상적으로 작동합니다. 그러나 내가 그것을 게시하고 다른 컴퓨터에 프로그램을 설치할 때. 충돌이 발생하고 INSERT 명령이 실행되지 않습니다.SQL 쿼리를 실행하지 않았습니다.
여기 내 코드입니다.
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 [email protected] AND [email protected]"
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를 클릭 한 후 충돌이 발생합니다.
데이터베이스 연결 (응용 프로그램과 함께 올바르게 실행되는 설치 또는 구성)에 문제가있을 수 있습니다. 응용 프로그램을 통해 예외 \ 오류를 기록하여 문제가 정확히 무엇인지 파악하십시오. – souser
어떻게 예외 \ 오류를 기록 할 수 있습니까? – shesxue28
엔터프라이즈 라이브러리의 로깅 모듈을 확인하십시오. 또는 간단한 텍스트 파일에 삽입 된 예외 정보를 기록 할 수도 있습니다. – souser