何が原因なのかはわかりませんが、最初にクエリを削除してからデータを挿入することで解決策を見つけました.
SQLStr = "delete FROM [Patient_Data].[dbo].[tbPatientImage] where HospNum='" & Session.Item("HospNum") & "'" & _ " and IDNum='" & Session.Item("IDNum") & "' and FileType= '" & lblHeader.Text & "'" Dim cmd As New SqlCommand(SQLStr, con) cmd.Connection = con con.Open() cmd.ExecuteNonQuery() SQLStr = " INSERT INTO [Patient_Data].[dbo].[tbPatientImage](HospNum,IDNum, DoctorID, PatImage , FileType, FileName, FileSize , TransDATE) " & _ " VALUES (@HospNum,@IDNum, @DoctorID, @Data, @FileType, 'Patient Photo' , @FileSize, GETDATE())" cmd.CommandText = SQLStr 'cmd.CommandTimeout = 120 cmd.Parameters.AddWithValue("@HospNum", Session.Item("HospNum")) cmd.Parameters.AddWithValue("@IDNum", Session.Item("IDNum")) cmd.Parameters.AddWithValue("@DoctorID", Session.Item("DoctorID")) cmd.Parameters.AddWithValue("@FileType", lblHeader.Text) cmd.Parameters.AddWithValue("@FileSize", FileSizeOfIMG) cmd.Parameters.Add(ImageTypeDataOfImage) cmd.ExecuteNonQuery() con.Close() GetData() lblMessage.Text = "Saved." End Using End Sub
プレ>