troubleshooting Question

VB.net sending emails based on new records

Avatar of DJ P
DJ P asked on
DatabasesVisual Basic.NETSQL
1 Comment1 Solution109 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
nociSoftware Engineer
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros