How to highlight certain criteria and perform an action upon this happening

Posted on 2004-11-29
Last Modified: 2010-04-23
I am new to and have to create a system that records marks of a test, the system has to detect when the marks of the test fall below standard and then recalls the details of the person using their id number and fills them into an email form, this details include the name and id number.  The system then is supposed to send the email to the supervisor, I am unable to do this web based due to the visual studio web environment not working correctly.  It has to send the email through MAPI to outlook and then take it from there.  I cannot even send it using SMTP because the SMTP on the server has been blocked.

I have not used before or connected to a database to carry out any of these actions.  If any help or examples could be provided it would be very much appreciated.

Any suggestions or help would be of great benefit to me.
Question by:perti83
    1 Comment
    LVL 8

    Accepted Solution

    Sample code using VB.Net and Ado.Net:

    1) You have to Import
    Imports System.Data.SqlClient

    2) Example uses three text boxes one for input and next two for results

    3)also two buttons(one selectbutton and updateButton to your form.)

    Select button event pulls information from employee table--northwind database for the typed forst name

    Update button event updates the last name and homephone for the firstname.

     Private Sub selectButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selectButton.Click
            'Clear the result textboxes
            TextBox2.Text = ""
            TextBox3.Text = ""

            'build sql connection string at run time
            Dim connect As New SqlConnection("Initial Catalog = Northwind;Data Source=(local); User ID=sa; password =test;")

            'open the connection

            'build sql string
            Dim sqlString As String
            sqlString = "Select LastName, HomePhone From Employees Where FirstName = '" & TextBox1.Text & "'"

            'open sql command object
            Dim command As New SqlCommand(sqlString, connect)

            'open sql data reader
            Dim reader As SqlDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)

            ' retrieve results through data reader
            If reader.Read() Then

                TextBox2.Text = reader("LastName")
                TextBox3.Text = reader("HomePhone")

            End If

            'clean up code
            connect = Nothing

        End Sub

    Private Sub UpdateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateButton.Click

            'build sql connection string at run time
            Dim connect As New SqlConnection("Initial Catalog = Northwind;Data Source=(local); User ID=sa; password =test;")

            'Opns the SQL Connection

            'open command object(takes two parameters sqlstring, connection)
            Dim command As New SqlCommand("Update Employees Set LastName = '" & TextBox2.Text & "'," _
                             & " HomePhone = '" & TextBox3.Text & "' where FirstName = '" & TextBox1.Text & "'", connect)

            'execute command object

            'clean up code
            connect = Nothing

        End Sub

    Hope it help.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now