Results 1 to 2 of 2

Thread: VB.net and mysql

  1. #1
    New Member
    Join Date
    Aug 12
    Posts
    1

    VB.net and mysql

    Name:  SQL.png
Views: 55
Size:  114.3 KB
    Help me with Saving and retrieving images into mysql
    Save Images im using it

    Code:
    Dim cmd As New MySqlCommand
            Dim adapter As New MySqlDataAdapter
            Call ConnectDB()
            If dup(txtfname.Text, txtmname.Text, txtlname.Text) = False Then
                If idup(txtid.Text) = False Then
                    If txtfname.Text <> "" And txtmname.Text <> "" And txtflname.Text <> "" And txtnname.Text <> "" And txtage.Text <> "" And txtbplace.Text <> "" And txtno.Text <> "" And txtaddress.Text <> "" And txttribe.Text <> "" And cboMonth.Text <> "" And cboday.Text <> "" And cboYear.Text <> "" And cbogender.Text <> "" And cboBaptized.Text <> "" And cboReligion.Text <> "" And cbonationality.Text <> "" And cboLevel.Text <> "" And cboClass.Text <> "" And cboFeduc.Text <> "" And cboMeduc.Text <> "" And cboGeduc.Text <> "" Then
                        If MsgBox("Are you sure you want to Save this record?", _
                   vbYesNo + vbQuestion, _
                   "Save Data") = vbYes Then
                            Call ConnectDB()
                            strsql = "Insert into student(firstname,middlename,lastname,nickname,age,gender,month,day,year,baptized,nationality,religion,birthplace,tribe,phone,address,flname,ffname,fmname,foccupation,feducational,mlname,mfname,mmname,moccupation,meducational,guardian,goccupation,geducational,addresspg,level,Class,photo)values(@field2,@field3,@field4,@field5,@field6,@field7,@field8,@field9,@field10,@field11,@field12,@field13,@field14,@field15,@field16,@field17,@field18,@field19,@field20,@field21,@field22,@field23,@field24,@field25,@field26,@field27,@field28,@field29,@field30,@field31,@field32,@field33,@field34)"
                            cmd = New MySql.Data.MySqlClient.MySqlCommand(strsql, myconn)
                            With cmd
                                '.Parameters.AddWithValue("@field1", txtid.Text)
                                .Parameters.AddWithValue("@field2", txtfname.Text)
                                .Parameters.AddWithValue("@field3", txtmname.Text)
                                .Parameters.AddWithValue("@field4", txtlname.Text)
                                .Parameters.AddWithValue("@field5", txtnname.Text)
                                .Parameters.AddWithValue("@field6", txtage.Text)
                                .Parameters.AddWithValue("@field7", cbogender.Text)
                                .Parameters.AddWithValue("@field8", cboMonth.Text)
                                .Parameters.AddWithValue("@field9", cboday.Text)
                                .Parameters.AddWithValue("@field10", cboYear.Text)
                                .Parameters.AddWithValue("@field11", cboBaptized.Text)
                                .Parameters.AddWithValue("@field12", cbonationality.Text)
                                .Parameters.AddWithValue("@field13", cboReligion.Text)
                                .Parameters.AddWithValue("@field14", txtbplace.Text)
                                .Parameters.AddWithValue("@field15", txttribe.Text)
                                .Parameters.AddWithValue("@field16", txtno.Text)
                                .Parameters.AddWithValue("@field17", txtaddress.Text)
                                .Parameters.AddWithValue("@field18", txtflname.Text)
                                .Parameters.AddWithValue("@field19", txtffname.Text)
                                .Parameters.AddWithValue("@field20", txtfmname.Text)
                                .Parameters.AddWithValue("@field21", txtFoccupation.Text)
                                .Parameters.AddWithValue("@field22", cboFeduc.Text)
                                .Parameters.AddWithValue("@field23", txtmlname.Text)
                                .Parameters.AddWithValue("@field24", txtmfname.Text)
                                .Parameters.AddWithValue("@field25", txtmmname.Text)
                                .Parameters.AddWithValue("@field26", txtmoccupation.Text)
                                .Parameters.AddWithValue("@field27", cboMeduc.Text)
                                .Parameters.AddWithValue("@field28", txtGuardian.Text)
                                .Parameters.AddWithValue("@field29", txtgoccupation.Text)
                                .Parameters.AddWithValue("@field30", cboGeduc.Text)
                                .Parameters.AddWithValue("@field31", txtaddresspg.Text)
                                .Parameters.AddWithValue("@field32", cboLevel.Text)
                                .Parameters.AddWithValue("@field33", cboClass.Text)
                                .Parameters.AddWithValue("@field34", TextBox1.Text)
                            End With
                            cmd.ExecuteNonQuery()
                            cmd.Dispose()
                            MsgBox("New Student has beed added", MsgBoxStyle.Information, "System Information")
                            Me.Hide()
                            Receipt.btnTotal.Enabled = False
                            Receipt.Show()
                            'Receipt.txtid.Text = txtid.Text
                            Receipt.txtlname.Text = txtlname.Text
                            Receipt.txtfname.Text = txtfname.Text
                            Receipt.txtmname.Text = txtmname.Text
                            Receipt.txtLevel.Text = cboLevel.Text
                            Receipt.txtTuition.Text = "7000"
                            txtnname.Text = ""
                            txtage.Text = ""
                            txttribe.Text = ""
                            txtbplace.Text = ""
                            txtno.Text = ""
                            txtaddress.Text = ""
                            txtflname.Text = ""
                            txtffname.Text = ""
                            txtfmname.Text = ""
                            txtFoccupation.Text = ""
                            txtmlname.Text = ""
                            txtmfname.Text = ""
                            txtmmname.Text = ""
                            txtmoccupation.Text = ""
                            txtGuardian.Text = ""
                            txtgoccupation.Text = ""
                            txtaddresspg.Text = ""
                            cbogender.Text = ""
                            cboBaptized.Text = ""
                            cboMonth.Text = ""
                            cboday.Text = ""
                            cboYear.Text = ""
                            cbonationality.Text = ""
                            cboReligion.Text = ""
                            cboClass.Text = ""
                            pPic2x2.Image = Nothing
                            Label26.Visible = True
                            txtfname.Focus()
                        Else
                            Me.Focus()
                        End If
                    Else
                        MsgBox("All Fields must required", MsgBoxStyle.Information, "System Message")
                        txtfname.Focus()
                    End If
                Else
                    MsgBox("Sorry,No. " + txtid.Text + " Already Exists", MsgBoxStyle.Critical, "Duplicate")
                    txtid.Text = ""
                    txtid.Focus()
                End If
            Else
                MsgBox("Sorry,Student Already Exists", MsgBoxStyle.Critical, "Duplicate")
                txtid.Text = ""
                txtfname.Text = ""
                txtmname.Text = ""
                txtlname.Text = ""
                txtnname.Text = ""
                txtfname.Focus()
            End If
            Call disconnectDB()
            Me.filllistview()
        End Sub
    
    but then if i retrieve my image using listview this is my codes
    
     With Listview1.SelectedItems(0)
                txtid.Text = .SubItems(0).Text
                txtlname.Text = .SubItems(1).Text
                txtfname.Text = .SubItems(2).Text
                txtmname.Text = .SubItems(3).Text
                txtnname.Text = .SubItems(4).Text
                txtage.Text = .SubItems(5).Text
                cbogender.Text = .SubItems(6).Text
                cboMonth.Text = .SubItems(7).Text
                cboday.Text = .SubItems(8).Text
                cboYear.Text = .SubItems(9).Text
                cboBaptized.Text = .SubItems(10).Text
                cbonationality.Text = .SubItems(11).Text
                cboReligion.Text = .SubItems(12).Text
                txtbplace.Text = .SubItems(13).Text
                txttribe.Text = .SubItems(14).Text
                txtno.Text = .SubItems(15).Text
                txtaddress.Text = .SubItems(16).Text
                txtflname.Text = .SubItems(17).Text
                txtffname.Text = .SubItems(18).Text
                txtfmname.Text = .SubItems(19).Text
                txtFoccupation.Text = .SubItems(20).Text
                cboFeduc.Text = .SubItems(21).Text
                txtmlname.Text = .SubItems(22).Text
                txtmfname.Text = .SubItems(23).Text
                txtmmname.Text = .SubItems(24).Text
                txtmoccupation.Text = .SubItems(25).Text
                cboMeduc.Text = .SubItems(26).Text
                txtGuardian.Text = .SubItems(27).Text
                txtgoccupation.Text = .SubItems(28).Text
                cboGeduc.Text = .SubItems(29).Text
                txtaddresspg.Text = .SubItems(30).Text
                cboLevel.Text = .SubItems(31).Text
                cboClass.Text = .SubItems(32).Text
            End With
    Please need your help
    Last edited by koolsid; Aug 5th, 2012 at 02:38 AM. Reason: Code Tags Added

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,763

    Re: VB.net and mysql

    Follow the CodeBank link in my signature and check out my thread on Saving Images In Databases.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •