Option Explicit On Imports System.Data Imports System.Data.SqlClient Public Class mission Inherits System.Web.UI.Page Dim SQL As String Dim DS As New DataSet Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then Try '---fill DDP list box by running sp_GetDDP Dim Result As Boolean Result = ManageSP.Run_SP(DS, "GetDDP", "dbo.GetDDP", "DDP") If Result = False Then Throw New Exception lbDDP.DataSource = DS.Tables("DDP") 'tell list box which table & field to use lbDDP.DataValueField = "DDPCode" 'list box uses this field as the index/key lbDDP.DataTextField = "Description" 'the field to display to the user lbDDP.DataBind() '---fill years LB by running sp_GetYears Result = ManageSP.Run_SP(DS, "GetYears", "dbo.GetYears", "Years") If Result = False Then Throw New Exception lbYear.DataSource = DS.Tables("Years") lbYear.DataTextField = "YrNeeded" lbYear.DataBind() Catch err As Exception DisplayError() End Try End If End Sub Private Sub DisplayError() lblError.Visible = True btnSubmit.Enabled = False End Sub Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Try Dim ConnString As String ConnString = ConfigurationSettings.AppSettings("ConnectionString") Dim Conn As New SqlConnection(ConnString) Dim Cmd As New SqlCommand Cmd.Connection = Conn Cmd.CommandText = "INSERT INTO Vision (DDPCode, Mission, Vision, YrNeeded) VALUES ( @NewDDP,@NewMission,@NewVision,@NewYr)" With Cmd .Parameters.Add("@NewDDP", SqlDbType.SmallInt).Value = lbDDP.SelectedValue .Parameters.Add("@NewMission", SqlDbType.NText).Value = txtMission.Text .Parameters.Add("@NewVision", SqlDbType.NText).Value = txtVision.Text .Parameters.Add("@NewYr", SqlDbType.NVarChar).Value = lbYear.SelectedItem.Text End With Conn.Open() Cmd.ExecuteNonQuery() Conn.Close() Session("MyDDPDescrip") = lbDDP.SelectedItem.Text Session("MyYear") = lbYear.SelectedItem.Text Session("MyVision") = txtVision.Text Session("MyMission") = txtMission.Text Response.Redirect("Feedback-Mission.aspx") Catch MyError As Exception DisplayError() End Try End Sub End Class