Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-11-29
3
Medium Priority
?
141 Views
Last Modified: 2010-04-23
I am new to vb.net 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 vb.net 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.
0
Comment
Question by:perti83
1 Comment
 
LVL 8

Accepted Solution

by:
mani_sai earned 2000 total points
ID: 12699836
Sample code using VB.Net and Ado.Net:

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

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
        connect.Open()

        '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
        reader.Close()
        command.Dispose()
        connect.Close()
        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
        connect.Open()

        '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
        command.ExecuteNonQuery()


        'clean up code
        command.Dispose()
        connect.Close()
        connect = Nothing



    End Sub




Hope it help.

Thanks

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

810 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