Programming for Everybody

Step by step how to Connect SQL server Database with Visual Basic .net with Source code

Public Class Form1

    Private Sub Browse_btn_Click(sender As Object, e As EventArgs) Handles Browse_btn.Click

        OpenFileDialog1.Filter = "Image|*.png;*.jpg;*.bmp"

        If OpenFileDialog1.ShowDialog = DialogResult.OK Then

            pictxt.Text = OpenFileDialog1.FileName

            PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)

        Else

            pictxt.Text = ""

            PictureBox1.Image = Nothing

        End If

    End Sub


    Private Sub pictxt_TextChanged(sender As Object, e As EventArgs) Handles pictxt.TextChanged

        If pictxt.Text = "" Then

            PictureBox1.Image = Nothing

        Else

            PictureBox1.Image = Image.FromFile(pictxt.Text)

        End If

    End Sub


    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        'TODO: This line of code loads data into the 'Students3DataSet.Table1' table. You can move, or remove it, as needed.

        Me.Table1TableAdapter.Fill(Me.Students3DataSet.Table1)

        DataGridView1.Columns(4).DefaultCellStyle.Format = "MM/dd/yyyy"

        DataGridView1.Columns(0).HeaderText = "ID"

        DataGridView1.Columns(1).HeaderText = "Code"

        DataGridView1.Columns(2).HeaderText = "Name"

        DataGridView1.Columns(3).HeaderText = "Phone"

        DataGridView1.Columns(4).HeaderText = "Date"

        DataGridView1.Columns(5).HeaderText = "Grade"

        DataGridView1.Columns(6).HeaderText = "Class"

        DataGridView1.Columns(7).HeaderText = "Picture"

    End Sub


    Private Sub new_btn_Click(sender As Object, e As EventArgs) Handles new_btn.Click

        Dim row = DirectCast(Table1BindingSource.AddNew(), DataRowView)

        row("rdate") = dtp1.Value

    End Sub


    Private Sub save_btn_Click(sender As Object, e As EventArgs) Handles save_btn.Click

        If (String.IsNullOrEmpty(codetxt.Text)) Then

            ErrorProvider1.SetError(codetxt, "Code Is required")

        Else

            ErrorProvider1.SetError(codetxt, String.Empty)

            For i As Integer = 0 To DataGridView1.Rows.Count - 1

                If codetxt.Text = DataGridView1.Rows(i).Cells(1).Value.ToString And idtxt.Text <> DataGridView1.Rows(i).Cells(0).Value.ToString Then

                    MessageBox.Show("Code Exists Before")

                    Return

                Else

                    Table1BindingSource.EndEdit()

                    Table1TableAdapter.Update(Students3DataSet.Table1)

                End If

            Next

            MessageBox.Show("Data Saved Successfully")

        End If

    End Sub


    Private Sub codetxt_TextChanged(sender As Object, e As EventArgs) Handles codetxt.TextChanged

        If (String.IsNullOrEmpty(codetxt.Text)) Then

            ErrorProvider1.SetError(codetxt, "Code Is required")

        Else

            ErrorProvider1.SetError(codetxt, String.Empty)

        End If

    End Sub


    Private Sub delete_btn_Click(sender As Object, e As EventArgs) Handles delete_btn.Click

        Table1BindingSource.RemoveCurrent()

        Table1TableAdapter.Update(Students3DataSet.Table1)

        PictureBox1.Image = Nothing

    End Sub


    Private Sub first_btn_Click(sender As Object, e As EventArgs) Handles first_btn.Click

        Table1BindingSource.MoveFirst()

    End Sub


    Private Sub next_btn_Click(sender As Object, e As EventArgs) Handles next_btn.Click

        Table1BindingSource.MoveNext()

    End Sub


    Private Sub previous_btn_Click(sender As Object, e As EventArgs) Handles previous_btn.Click

        Table1BindingSource.MovePrevious()

    End Sub


    Private Sub last_btn_Click(sender As Object, e As EventArgs) Handles last_btn.Click

        Table1BindingSource.MoveLast()

    End Sub


    Private Sub close_btn_Click(sender As Object, e As EventArgs) Handles close_btn.Click

        Me.Close()

    End Sub


    Private Sub Search_btn_Click(sender As Object, e As EventArgs) Handles Search_btn.Click

        Me.Table1TableAdapter.search(Me.Students3DataSet.Table1, idtxt.Text)

    End Sub


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Me.Table1TableAdapter.Fill(Me.Students3DataSet.Table1)

    End Sub

End Class



 

How to add new column IIF in subform with change colors cells based on its value in MS Access forms

Learn how to add a new column with IIF function in a subform and change cell colors based on values in MS Access forms. Improve your form design skills with this tutorial!Videos Access
Subscribe to Youtube
 
https://www.youtube.com/@programmingcode2025/?sub_confirmation=1


Code copy table from one database to another database in MYSQL Workbench

 In this video, We will learn copy table from one database to another database in MYSQL Workbench

Subscribe to my channel to find everyday new information in programming and computer Science
"Love coding? Don’t miss out! Subscribe for the latest in programming trends and tech innovations!"
https://www.youtube.com/@programmingcode2025/?sub_confirmation=1
#mysql_tutorial
#mysql
#Wokbench
#mysql_workbench



Full course in 3 minutes connect command line with mysql Workbench

 Full course in 3 minutes connect command line with mysql Workbench

Subscribe to my channel to find everyday new information in programming and computer Science "Love coding? Don’t miss out! Subscribe for the latest in programming trends and tech innovations!" https://www.youtube.com/@programmingcode2025/?sub_confirmation=1 #mysql_tutorial #mysql #Wokbench #mysql_workbench


How to fill Combo box by field list in table in forms MS Access database without vba

 How to fill Combo box by field list in table in forms MS Access database without vba



"Love coding? Don’t miss out! Subscribe for the latest in programming trends and tech innovations!" https://www.youtube.com/@programmingcode2025/?sub_confirmation=1 #access #msaccess #vbaaccess #microsoft #microsoftaccess


How to use Microsoft Access - Beginner Tutorial 2025


Learn how to use Microsoft Access with this beginner tutorial. Whether you're new to Access or just need a refresher, this video will guide you through the basics of using this powerful database management tool.

Subscribe to my channel to find everyday new information in programming and Computerr Science Subscribe to @programmingforeverybody
https://www.youtube.com/@programmingforeverybody/?sub_confirmation=1