如何将picturebox1映像保存到mysql数据库?

时间:2017-11-24 16:31:59

标签: mysql vb.net

以下是我的保存按钮代码,任何人都可以帮我解决问题吗?提前致谢

Private Sub btnempsave_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)处理btnempsave.Click

    If rdomale.Checked = True Then
        rdo = "MALE"
    Else
        rdo = "FEMALE"
    End If
    sql = "INSERT INTO `employee_workinfo` (`emp_code`, `d_rate`, `p_method`, `position`, `w_status`, `d_hired`)" _
            & " VALUES ('" & txtcode.Text & "','" & txtdrate.Text & "','" & txtpmethod.Text & "','" & txtposition.Text _
            & "','" & txtworkstatus.Text & "','" & dtpdhired.Text & "')"
    createsub(sql)

    sql = "INSERT INTO `employee` (`emp_code`, `emp_fname`, `emp_lname`, `emp_mname`" _
    & ", `address`, `contact`, `status`, `birth_date`, `birth_place`, `emp_sex`, `emp_age`, `emerg_contct`" _
    & ", `emp_tin`, `course`, `email`, `gs`, `hs`, `college`, `ar1`, `ar2`, `ct`, `nm`, `am`, `pobm`, `gsm`, `hsm`, `cm`, `dfm`, `bam`, `religionm`, `nationalitym`, `aim`, `msm`, `nf`, `af`, `pobf`, `gsf`, `hsf`, `cf`, `dff`, `baf`, `religionf`, `nationalityf`, `aif`, `msf`, `allergies`, `ail`, `pia`, `hospital`, `w_when`, `c_cause`, `l_like`, `d_dislike`, `catholic`, `prestige`, `location`, `s_sr`, `offer`, `quality`, `choice`, `pdc`, `rtp`, `rrf`, `rts`, `cd`, `bpb`, `friends`, `parents`, `relatives`, `internet`, `oo_other`, `o_other`, `entrance`, `evaluation`, `personal`, `photo`) VALUES ('" & txtcode.Text & "','" & txtfname.Text & "','" & txtlname.Text _
    & "','" & txtmname.Text & "','" & txtaddress.Text & "','" & txtcontact.Text & "','" & txtstatus.Text _
    & "','" & dtpdbirth.Text & "','" & txtbplace.Text & "','" & rdo & "','" & txtage.Text & "','" & txtemerg.Text & "','" & texttin.Text _
    & "','" & txtcourse.Text & "','" & txtemail.Text _
    & "','" & txtgs.Text & "','" & txths.Text & "','" & txtc.Text & "','" & txtar1.Text & "','" & txtar2.Text & "','" & txtct.Text _
    & "','" & txtnm.Text & "','" & txtam.Text & "','" & txtpobm.Text & "','" & txtgsm.Text & "','" & txthsm.Text & "','" & txtcm.Text & "','" & txtdfm.Text & "','" & txtbam.Text & "','" & txtreligionm.Text & "','" & txtnationalitym.Text & "','" & txtaim.Text & "','" & txtmsm.Text _
    & "','" & txtnf.Text & "','" & txtaf.Text & "','" & txtpobf.Text & "','" & txtgsf.Text & "','" & txthsf.Text & "','" & txtcf.Text & "','" & txtdff.Text & "','" & txtbaf.Text & "','" & txtreligionf.Text & "','" & txtnationalityf.Text & "','" & txtaif.Text & "','" & txtmsf.Text _
    & "','" & txtallergies.Text & "','" & txtail.Text & "','" & txtpia.Text & "','" & txthospital.Text & "','" & txtwhen.Text & "','" & txtcause.Text & "','" & txtlike.Text & "','" & txtdislike.Text _
    & "','" & txtcatholic.Checked & "','" & txtprestige.Checked & "','" & txtlocation.Checked & "','" & txtsr.Checked & "','" & txtoffer.Checked & "','" & txtquality.Checked & "','" & txtchoice.Checked & "','" & txtpdc.Checked & "','" & txtrtp.Checked & "','" & txtrrf.Checked _
    & "','" & txtrts.Checked & "','" & txtcd.Checked & "','" & txtbpb.Checked & "','" & txtfriends.Checked & "','" & txtparents.Checked & "','" & txtrelatives.Checked & "','" & txtinternet.Checked & "','" & txtother2.Text & "','" & txtother1.Text _
    & "','" & TxtEntrance.Text & "','" & txtEvaluation.Text & "','" & txtPersonalE.Text & "',@Photo)"

    cmd.Parameters.Add("@Photo", MySqlDbType.LongBlob).Value = mstream.ToArray





    create(sql)
    Call btnempnew_Click(sender, e)



    btnempsave.Enabled = True
    btnempupdate.Enabled = False


    'MsgBox(ex.Message & " btnempsave_Click", MsgBoxStyle.Exclamation)

End Sub

0 个答案:

没有答案