locked
Question concerning information that isn't there RRS feed

  • Question

  • User-546863279 posted



    If type = "EXISTING" Then Dim projectID As String = Request.QueryString("projectID") lblProjectID.Text = projectID Dim startDate As String = "" Dim projectTitle As String = "" Dim projectCategory As String = "" Dim projectManager As String = "" Dim projectFacilitator As String = "" Dim projectType As String = "" Dim completionDate As Date Dim objConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|MOPPS.mdb;") Dim objSQL As String = "SELECT StartDate, ProjectTitle, ProjectCategory, ProjectType, Facilitator, Manager, ProjectDescription, Notes, Budget, LedgerNo, CompletionDate FROM Projects WHERE ProjectID=@projectID;" Dim objCommand As New OleDbCommand(objSQL, objConnection) Dim objDataReader As OleDbDataReader Const selectProjectTypesSQL As String = "SELECT [Project Type] FROM refProjectType" Const selectPersonnelSQL As String = "SELECT Personnel FROM refPersonnel" Dim selectProjectTypeCommand As New OleDbCommand(selectProjectTypesSQL, objConnection) Dim selectFacilitatorCommand As New OleDbCommand(selectPersonnelSQL, objConnection) Dim selectManagerCommand As New OleDbCommand(selectPersonnelSQL, objConnection) Dim selectProjectTypeDataReader As OleDbDataReader Dim selectFacilitatorDataReader As OleDbDataReader Dim selectManagerDataReader As OleDbDataReader Using objConnection Using objCommand objCommand.Parameters.AddWithValue("projectID", projectID) objConnection.Open() objCommand.ExecuteNonQuery() objDataReader = objCommand.ExecuteReader() While (objDataReader.Read()) startDate = objDataReader.GetDateTime(0).ToString() projectTitle = objDataReader.GetValue(1).ToString() projectCategory = objDataReader.GetValue(2).ToString() lblStartDateLOAD.Text = Convert.ToDateTime(startDate).ToString("dd.MM.yyyy") lblProjectTitleLOAD.Text = projectTitle lblProjectCategoryLOAD.Text = projectCategory projectType = objDataReader.GetValue(3).ToString() projectFacilitator = objDataReader.GetValue(4).ToString() projectManager = objDataReader.GetValue(5).ToString() tbProjectDescription.Text = objDataReader.GetValue(6).ToString() tbNotes.Text = objDataReader.GetValue(7).ToString() tbBudget.Text = objDataReader.GetValue(8).ToString() tbMasterNo.Text = objDataReader.GetValue(9).ToString() completionDate = objDataReader.GetDateTime(10).ToString() End While End Using Using selectProjectTypeCommand selectProjectTypeDataReader = selectProjectTypeCommand.ExecuteReader() ddlProjectType.DataSource = selectProjectTypeDataReader ddlProjectType.DataBind() End Using Using selectFacilitatorCommand selectFacilitatorDataReader = selectFacilitatorCommand.ExecuteReader() ddlFacilitator.DataSource = selectFacilitatorDataReader ddlFacilitator.DataBind() End Using Using selectManagerCommand selectManagerDataReader = selectManagerCommand.ExecuteReader() ddlManager.DataSource = selectManagerDataReader ddlManager.DataBind() End Using End Using ddlManager.SelectedValue = projectManager ddlFacilitator.SelectedValue = projectFacilitator ddlProjectType.SelectedValue = projectType Dim completionDay As String = Convert.ToDateTime(completionDate).ToString("dd") Dim completionMonth As String = Convert.ToDateTime(completionDate).ToString("MM") Dim completionYear As Integer = Convert.ToDateTime(completionDate).ToString("yyyy") completionYear = completionYear - 2000 ddlCompleteDateDay.SelectedValue = completionDay ddlCompleteDateMonth.SelectedValue = completionMonth tbCompleteDateYear.Text = completionYear End If End If



    Tuesday, October 12, 2010 10:05 PM

Answers

  • User-1661238708 posted

    put your code inside:

    try

       code here

    catch

    end try 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 14, 2010 1:29 AM

All replies

  • User-546863279 posted

    How can I make it so that if the database doesn't have a piece of information (ie. Budget) for whatever reason, the whole program doesn't crash.

    Wednesday, October 13, 2010 7:00 PM
  • User-1661238708 posted

    put your code inside:

    try

       code here

    catch

    end try 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 14, 2010 1:29 AM