0

このコードを使用して検索および編集できません。挿入は機能しています。ただし、挿入コーディング方法がわかりません ( fileContent.ToString)。また、検索部分と更新部分が機能していません。

Dim fileContent As Byte() = My.Computer.FileSystem.ReadAllBytes(OpenFileDialog1.FileName)

Sub NormalUpdate(ByVal _Query)
    con.Open()
    Dim cmdUpdate As New SqlCommand(_Query)

    cmdUpdate.Connection = con
    cmdUpdate.CommandType = CommandType.Text
    cmdUpdate.ExecuteNonQuery()
    con.Close()
End Sub

Sub NormalSave(ByVal _Query)
    con.Open()
    Dim cmdSave As New SqlCommand(_Query)

    cmdSave.Connection = con
    cmdSave.CommandType = CommandType.Text
    cmdSave.ExecuteNonQuery()
    con.Close()
End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
    NormalSave("Insert into Registration values('" + txtMemberNo.Text + "','" + fileContent.ToString + "')")
End Sub

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
    con.Open()
    Using cmd As New SqlClient.SqlCommand("Select MemberPicture From Registration where MemberNo = '" + txtMemberNo.Text + "'", con)
        Using dr As SqlClient.SqlDataReader = cmd.ExecuteReader()
            Using dt As New DataTable
                dt.Load(dr)
                Dim row As DataRow = dt.Rows(0)
                Using ms As New IO.MemoryStream(CType(row("MemberPicture"), Byte()))
                    Dim img As Image = Image.FromStream(ms)
                    ProfilePic.Image = img
                    con.Close()
                End Using
            End Using
        End Using
    End Using
End Sub

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click        
    NormalUpdate("Update Registration set MemberPicture = '" + fileContent.ToString + "' where MemberNo = '" + txtMemberNo.Text + "'")
End Sub

私を助けてください。ありがとう。

4

2 に答える 2