Run a Insert...Select statement from a Web page.

CloudApps
CloudApps used Ask the Experts™
on
I have a web page that launches a Crystal Report. The report prints mailing labels for expiration notices that are being sent out.

I need to append records to an event history table in the database for the expiration notices.

Here is the Visual Basic code for the button that launches the labels:
--------------------------------------------------------------------------------------------------------------------------------
   Protected Sub Button_Preview_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button_Preview.Click

        If (Session("report") Is Nothing) Then

            Dim rd As New ReportDocument
            rd.Load(Server.MapPath("ExpirationNoticesMailingLabels.rpt"))
            Dim boConnectionInfo As CrystalDecisions.Shared.IConnectionInfo

            For Each boConnectionInfo In rd.DataSourceConnections
                boConnectionInfo.SetLogon("UserName", "Password")
            Next

            Session.Add("report", rd)
            CrystalReportViewer1.ReportSource = Session("Report")
            rd.SetParameterValue("Months To Expiration", Me.MonthsToExpiration.SelectedValue)

        End If

    End Sub
------------------------------------------------------------------------------------------------------------------------------

Please point me in the right direction for executing my Insert...Select statement.

Thanks,
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014
Commented:
Insert makes sense but why Select?

Dim dbcon As New SqlConnection("connection string")
dbcon.Open()
Dim dbcmd As New SqlCommand("Insert Into ...", dbcon)
dbcmd.ExecuteNonQuery()
dbcmd.dispose
dbcon.dispose
CloudAppsOwner

Author

Commented:
CodeCruiser,

I was refering to an INSERT INTO with a SELECT statement instead of a VALUE statement.

After some additional research, I have created a Stored Procedure to be executed.

Thanks for the help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial