如何将图像插入Access数据库OLEobject字段

时间:2015-12-08 12:53:06

标签: mysql ms-access vb.net-2010

我试图通过执行以下代码块将图像插入到OLEobject字段中。

    Private Sub BtnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnRegister.Click
        con.Open()
        Dim cmd As OleDbCommand = New OleDbCommand("INSERT INTO `Std_Registeration` (`CNIC`, `Std_Name`, `Father_Name`, `Reg_number`, `Gender`, `Department`, `Semester`,`Std_Picture`, `Email`, `Password`) VALUES ('" & CNICTextBox.Text & "','" & Std_NameTextBox.Text & "','" & Father_NameTextBox.Text & "','" & Reg_numberTextBox.Text & "','" & GenderComboBox.Text & "','" & DepartmentTextBox.Text & "','" & SemesterTextBox.Text & "','" & Std_PicturePictureBox.ImageLocation & "','" & EmailTextBox.Text & "','" & PasswordTextBox.Text & "')", con)
        Dim i As Integer = cmd.ExecuteNonQuery()
        If (i > 0) Then
            MessageBox.Show("Registeration Successful!")
        Else
            MessageBox.Show("OOPS! Something went wrong. Try Again!")
        End If
        con.Close()
    End Sub

我知道将ImageLocation发送到OLEobject没有任何意义。它需要转换成二进制或类似的东西。我想正确地将图像插入数据库字段(OlEobject)。

0 个答案:

没有答案