We help IT Professionals succeed at work.

VB.net sending emails based on new records

104 Views
Last Modified: 2018-06-08
Hello experts. I have a vb.net form that connects to a hosted MySQL database which contains a table for visitor data. As a secondary check (which I won't get into the reasons why) what I would ultimately like to do is hit a button that checks for any new records that were added to the table and send out an email showing which records were added. I created a form that connects to the database and have the datagridview showing all the records just to verify I am connecting with no issues. Its the code behind the button which I described above that I have zero clue how to accomplish. Below is what I have so far. Any help for a newbie learning to code which be most helpful.

App Configure Tab:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
    </startup>

  <connectionStrings>
    <add name="dbx" connectionString="server=xxxxxx;user id=xxxxx=;Password=xxxxxxxxx;database=XXXXXXX" providerName="MySqlData.MySqlClient" />
  </connectionStrings>
</configuration>

Form:

Imports System.Configuration
Imports MySql.Data
Imports MySql.Data.MySqlClient


Public Class Form2
    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        DataGridView1.DataSource = GetVisitorsList()
    End Sub

    Private Function GetVisitorsList() As DataTable
        Dim dtVisitors As New DataTable
        Dim connstring As String = ConfigurationManager.ConnectionStrings("dbx").ConnectionString

        Using conn As New MySqlConnection(connstring)
            Using cmd As New MySqlCommand("Select FirstName, LastName, Company, Country, USCitizen, Citizenship, DateSubmitted From visitors order by DateSubmitted ASC", conn)


                conn.Open()

                Dim reader As MySqlDataReader = cmd.ExecuteReader()
                dtVisitors.Load(reader)


            End Using

        End Using

        Return dtVisitors



    End Function
End Class
Comment
Watch Question

Software Engineer
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.