Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RESPONSE REDIRECT ISSUE ON SUBMIT

Posted on 2011-02-14
3
Medium Priority
?
571 Views
Last Modified: 2012-05-11
I have attached the VB "Behind Code" for a form that when submitted sends data to the data base and
a subsequent e-mail.

Everything works as desired except the "Response Redirect".   It redirect to an unknow page but the e-mail and data
is sent.   Need help working out the "Response Redirect" problem.
Imports System.Net
Imports System.Net.Mail

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim con As New System.Data.OleDb.OleDbConnection

        Dim myPath As String 
        myPath = Server.MapPath("database2.mdb")

        con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & myPath & ";"
        Dim myCommand As New System.Data.OleDb.OleDbCommand

        myCommand.CommandText = String.Format("INSERT INTO AOS([Dates],[Ship],[ArrTime],[InFlt],[History],[ETRDate],[ETRTime],[Station],[Reason1],[Status1],[Updated],[Reason2],[Parts]) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}')", DateTime.Parse(Dates.Text), Ship.Text, ArrTime.Text, InFlt.Text, History.Text, DateTime.Parse(ETRDate.Text), ETRTime.Text, Station.Text, Reason1.Text, Status1.Text, Updated.Text, Reason2.Text, Parts.Text)
        myCommand.Connection = con
        con.Open()
        myCommand.ExecuteNonQuery()
        con.Close()

        'Send Email
        Dim smtpClient As SmtpClient = New SmtpClient()
        Dim message As MailMessage = New MailMessage()
        Dim fromAddress As MailAddress = New MailAddress("AOS_Report@laxpm.com") 
        message.From = fromAddress
        message.To.Add("mark@laxpm.com")
        message.Bcc.Add("mark@laxpm.com")
        message.Subject = "AOS EVENT"

        Dim palinBody As String = "Ship: " & Ship.Text & ""



        Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString(palinBody, Nothing, "text/plain")
        Dim htmlBody As String = "<p>Ship: " & Ship.Text & ""




        Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(htmlBody, Nothing, "text/html")
        message.AlternateViews.Add(plainView)
        message.AlternateViews.Add(htmlView)
        message.Priority = MailPriority.High
        smtpClient.Host = "mail.laxpm.com"
        smtpClient.Send(message)

        Response.Redirect("http://las.laxpm.com/index.aspx")

    End Sub
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

End Class

Open in new window

0
Comment
Question by:BOEING39
3 Comments
 
LVL 10

Accepted Solution

by:
himanshut earned 1000 total points
ID: 34894030
to which page does it redirect?
Other than http://las.laxpm.com/index.aspx
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 1000 total points
ID: 34894061

Is this is different site or your own site form where you are calling this

then try
Response.Redirect("index.aspx")

else try

Server.Transfer("http://las.laxpm.com/index.aspx")
0
 

Author Closing Comment

by:BOEING39
ID: 34894121
Guys thx for the help.   I used the Server Redirect with a different address which worked....
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

972 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