0

Hi all,

I'm not the best with coding and was wondering if some one can help me out.

The page is inserting information into a database but when i added an extra section to insert i get the error

Could not find stored procedure 'Insert_PublicationsA'. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: Could not find stored procedure 'Insert_PublicationsA'.

Source Error: 


Line 740:
Line 741:        myConnection.Open()
Line 742:        myCommand.ExecuteNonQuery()
Line 743:        myConnection.Close()
Line 744:

The .vb is as follows:

Imports System.IO
Imports System.Data
Imports System.Data.SqlClient

Partial Class Admin_Insert_Publications
    Inherits System.Web.UI.Page

    Dim FileUpload_Name As String

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

        If Not Me.IsPostBack Then

            If Session("UserID") <> "Admin" Or Session("Active") = "False" Then
                Response.Redirect("Login.aspx")

            ElseIf Session("UserID") = "Admin" And Session("Active") = "True" Then
                'PopulateDetails(Session("UserID"))
                Session("FileInKB") = ""

            End If
        Else

            If Session("UserID") = "" Or Session("Active") = "False" Then
                Response.Redirect("Login.aspx?Name=true")

            ElseIf Session("UserID") <> "" Then
                ' PopulateDetails(Session("UserID"))
            End If
        End If


    End Sub


    Protected Sub btnUploadfile_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUploadfile.Click

        lblStatus.Visible = True

        If Session("RefNO") = "" Then

            generateRefNo()

        End If

        If FileUpload1.HasFile Then

            '// Get a reference to PostedFile object
            Dim MyFile As HttpPostedFile = FileUpload1.PostedFile

            '// Get size of uploaded file
            Dim nFileLen As Integer
            nFileLen = MyFile.ContentLength
            Dim FileInKB As Integer
            FileInKB = nFileLen / 1024

            Dim Filename As String
            Filename = System.IO.Path.GetFileName(FileUpload1.FileName)
            FileUpload_Name = System.IO.Path.GetFileName(FileUpload1.FileName)
            Session("FileUpload_Name") = FileUpload_Name
            Session("FileInKB") = FileInKB

            'MyFile = Me.FileUpload1.FileName
            'Dim finfo As System.IO.FileInfo
            'finfo = New System.IO.FileInfo(Server.MapPath(MyFile))
            'FileInBytes = finfo.Length
            'FileInKB = finfo.Length / 1024

            If FileInKB > 10000 Then
                Say("Please select a Publiaction file less than 10Mb")

            Else

                If Validate1() Then

                    Try
                        'Session("UserID") = "Maulik11"
                        Dim filepath As String = "D:\FarmCentral\image"
                        'Dim userPostedFile As HttpPostedFile = uploadedFiles(i)

                        lblStatus.Text = "Uploading File " + FileUpload1.FileName

                        'Server.MapPath("C:\Projects\LPA\LPA.WEB\CancellationPDF\" + session("PIC") + FileUpload.FileName

                        FileUpload1.SaveAs(Request.PhysicalApplicationPath + "pdf/" + Filename)

                        'FileUpload1.SaveAs("C:/Inetpub/farmcentral/FarmCentral/FarmCentral/image/" + Session("userid") + ".gif")

                        lblStatus.Text = "You have successfully uploaded a publication document"

                        'To do insert
                        'Dim myCancellationRequest As New CancellationRequestsEntity
                        'myCancellationRequest.Pic = Session("PIC")
                        'myCancellationRequest.UserId = Session("UserID")
                        'myCancellationRequest.Comment = Me.tbComment.Text
                        'myCancellationRequest.FileName = FileUpload1.FileName
                        'myCancellationRequest.Save()

                    Catch ex As Exception
                        lblStatus.Text = "ERROR: " + ex.Message.ToString()
                    End Try

                End If
            End If

        Else
            lblStatus.Text = "You have to select a file to upload"
        End If
    End Sub

    Private Sub Say(ByVal Message As String)
        ltlAlert.Text = Message
        ' Format string properly
        Message = Message.Replace("'", "\'")
        Message = Message.Replace(Convert.ToChar(10), "\n")
        Message = Message.Replace(Convert.ToChar(13), "")
        ' Display as JavaScript alert
        ltlAlert.Text = "alert('" & Message & "')"
    End Sub

    Private Sub generateRefNo()

        'Say("Successfully Reached")
        'Dim RefNo As String
        Dim myConnection As SqlConnection = New SqlConnection(ConfigurationManager.AppSettings("ConnectionString"))
        Dim myCommand As SqlCommand = New SqlCommand("PDFRefNo", myConnection)

        ' Mark the Command as a SPROC
        myCommand.CommandType = CommandType.StoredProcedure
        ' Add Parameters to SPROC

        myConnection.Open()

        Dim myReader As SqlDataReader
        myReader = myCommand.ExecuteReader

        ' Always call Read before accessing data.
        If myReader.Read Then

            Session("RefNO") = myReader.Item("UniqueID")

            'Response.Redirect("login.aspx")

        End If
        ' always call Close when done reading.
        myReader.Close()
        ' Close the connection when done with it.
        myConnection.Close()

    End Sub

    Private Function Validate1() As Boolean

        'Check valid image format

        If Regex.IsMatch(Me.FileUpload1.FileName, "^.*[.gif]$") Then
            Return True

        ElseIf Regex.IsMatch(Me.FileUpload1.FileName, "^.*[.JPEG]$") Then
            Return True

        ElseIf Regex.IsMatch(Me.FileUpload1.FileName, "^.*[.jpg]$") Then
            Return True

        ElseIf Regex.IsMatch(Me.FileUpload1.FileName, "^.*[.jpe]$") Then
            Return True

        ElseIf Regex.IsMatch(Me.FileUpload1.FileName, "^.*[.jfif]$") Then
            Return True

        ElseIf Regex.IsMatch(Me.FileUpload1.FileName, "^.*[.bmp]$") Then
            Return True

        ElseIf Regex.IsMatch(Me.FileUpload1.FileName, "^.*[.tiff]$") Then
            Return True

        ElseIf Regex.IsMatch(Me.FileUpload1.FileName, "^.*[.tif]$") Then
            Return True

        ElseIf Regex.IsMatch(Me.FileUpload1.FileName, "^.*[.png]$") Then
            Return True

        ElseIf Regex.IsMatch(Me.FileUpload1.FileName, "^.*[.pdf]$") Then
            Return True

        Else

            Say("Please Select Only image file - .gif, .bmp, .jpg, .jpeg, .jpe, .jfif, .gif, .tiff, .tif, .png, .pdf")
            Return False

        End If

        Return True

    End Function



    Protected Sub ChkAll_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ChkAll_Crop.CheckedChanged

        If Me.ChkAll_Crop.Checked = True Then

            Me.ChkAdBean.Checked = True
            Me.ChkChickPea.Checked = True
            Me.chkFabaBean.Checked = True
            Me.chkFieldPea.Checked = True
            Me.ChkLentil.Checked = True
            Me.ChkLupin.Checked = True
            Me.ChkMungbean.Checked = True
            Me.ChkVetch.Checked = True


        Else

            Me.ChkAdBean.Checked = False
            Me.ChkChickPea.Checked = False
            Me.chkFabaBean.Checked = False
            Me.chkFieldPea.Checked = False
            Me.ChkLentil.Checked = False
            Me.ChkLupin.Checked = False
            Me.ChkMungbean.Checked = False
            Me.ChkVetch.Checked = False


        End If

    End Sub


    Protected Sub BtnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSubmit.Click

        If Me.BtnSubmit.Text = "Submit" Then

            If ValidateInput() Then


                If Session("RefNO") = "" Then

                    generateRefNo()

                End If

                'insert data into database
                Insert_Publications()
                Insert_PublicationsA()

                Session("RefNO") = ""

                'make the panel un-enable
                Me.PnlBody.Enabled = False
                'make the success panel visible
                Me.PnlSuccess.Visible = True

                Me.BtnSubmit.Text = "Submit Again"

            End If

        Else

            Me.PnlBody.Enabled = True

            'Uncheck all Crops
            Me.ChkAdBean.Checked = False
            Me.ChkChickPea.Checked = False
            Me.chkFabaBean.Checked = False
            Me.chkFieldPea.Checked = False
            Me.ChkLentil.Checked = False
            Me.ChkLupin.Checked = False
            Me.ChkMungbean.Checked = False
            Me.ChkVetch.Checked = False
            Me.ChkAll_Crop.Checked = False

            'Uncheck all Organisations
            Me.ChkPulse_Australia.Checked = False
            Me.ChkAMA.Checked = False
            Me.ChkVictoria_DPI.Checked = False
            Me.ChkGRDC_Publication.Checked = False
            Me.ChkGRDC_Project.Checked = False
            Me.ChkWestern_DAFWA.Checked = False
            Me.ChkNew_South_INSW.Checked = False
            Me.ChkQueensland_DPI.Checked = False
            Me.ChkSouth_Australia.Checked = False
            Me.ChkAll_Organisations.Checked = False

            'Uncheck all Regions
            Me.ChkNorthern_region.Checked = False
            Me.ChkSouthern_Region.Checked = False
            Me.ChkWestern_Region.Checked = False
            Me.ChkAll_Regions.Checked = False

            'Uncheck all Category/Topic
            Me.ChkCrop_Management.Checked = False
            Me.ChkRotation_Planning.Checked = False
            Me.ChkGross_Margins.Checked = False
            Me.ChkVarietes.Checked = False
            Me.ChkCrop_nutrition.Checked = False
            Me.ChkCrop_Establishment.Checked = False
            Me.ChkWeed_Management.Checked = False
            Me.ChkInsect_Management.Checked = False
            Me.ChkHarvest_Storage.Checked = False
            Me.ChkMarketing.Checked = False
            Me.ChkPulse_Uses.Checked = False
            Me.ChkPulse_Update.Checked = False
            Me.ChkPulse_Tech_Notes.Checked = False
            Me.ChkAll_Category.Checked = False

            'Me.DDLPublicationType.SelectedIndex = "0"
            Me.TbTitle.Text = ""
            Me.TbKeywords.Text = ""

            Me.lblStatus.Visible = False
            Me.PnlSuccess.Visible = False

            Session("FileInKB") = ""
            Session("FileUpload_Name") = ""

            'Generating new Refrence Number
            generateRefNo()

            Me.BtnSubmit.Text = "Submit"

        End If




    End Sub

    


    Protected Sub Insert_Publications()

        '@UserID varchar(20),  

        '@AdBean int,
        '@ChickPea int,
        '@FabaBean int,
        '@FieldPea int,

        '@Lentil int,
        '@Lupin int,
        '@Mungbean int,
        '@Vetch int,
        '@Org_Pulse_Australia int,
        '@Org_AMA int,
        '@Org_VIC_DPI int,
        '@Org_GRDC_PUBLICATION int,
        '@Org_GRDC_Project int,
        '@Org_Western_DAFWA int,
        '@Org_INSW int,
        '@Org_Queensland_DEEDI int,
        '@Org_South_Australia int,


        '@Org_Result_Pulse_Australia int,
        '@Org_Result_AMA int,
        '@Org_Result_VIC_DPI int,
        '@Org_Result_GRDC_PUBLICATION int,
        '@Org_Result_GRDC_Project int,
        '@Org_Result_Western_DAFWA int,
        '@Org_Result_INSW int,
        '@Org_Result_Queensland_DEEDI int,
        '@Org_Result_SARDI int,
        '@Org_Result_Rural_SOl_SA int,
        '@Org_Result_PIRSA int,

        '@Region_Northern int,
        '@Region_Southern int,
        '@Region_Western int,

        '@Cat_Crop_Management int,
        '@Cat_Rotation_Planning int,
        '@Cat_Variete int,
        '@Cat_Crop_Nutrition int,
        '@Cat_Crop_Establishment int,
        '@Cat_Weed_Management int,
        '@Cat_Insect_Management int,
        '@Cat_Harvest_Storage int,
        '@Cat_Marketing int,
        '@Cat_Pulse_Uses int,

        '--@Publication varchar(100),
        '@Title varchar(200), 
        '@Keywords varchar(1000)
        '@FileInKB varchar(25)
        '@File_Name	varchar(1000),
        '@RefNo varchar(25)


        Dim myConnection As SqlConnection = New SqlConnection(ConfigurationManager.AppSettings("ConnectionString"))
        Dim myCommand As SqlCommand = New SqlCommand("Insert_Publications", myConnection)
        ' Mark the Command as a SPROC
        myCommand.CommandType = CommandType.StoredProcedure
        ' Add Parameters to SPROC

        '@UserID as varchar(20),

        Dim parameterUserID As SqlParameter = New SqlParameter("@UserID", SqlDbType.VarChar, 30)
        parameterUserID.Value = Session("UserID")
        myCommand.Parameters.Add(parameterUserID)


        '@AdBean int,
        Dim parameterAdBean As SqlParameter = New SqlParameter("@AdBean", SqlDbType.Int)
        parameterAdBean.Value = CInt(Me.ChkAdBean.Checked)
        myCommand.Parameters.Add(parameterAdBean)

        '@ChickPea int,
        Dim parameterChickPea As SqlParameter = New SqlParameter("@ChickPea", SqlDbType.Int)
        parameterChickPea.Value = CInt(Me.ChkChickPea.Checked)
        myCommand.Parameters.Add(parameterChickPea)

        '@FabaBean int,
        Dim parameterFabaBean As SqlParameter = New SqlParameter("@FabaBean", SqlDbType.Int)
        parameterFabaBean.Value = CInt(Me.chkFabaBean.Checked)
        myCommand.Parameters.Add(parameterFabaBean)

        '@FieldPea int,
        Dim parameterFieldPea As SqlParameter = New SqlParameter("@FieldPea", SqlDbType.Int)
        parameterFieldPea.Value = CInt(Me.chkFieldPea.Checked)
        myCommand.Parameters.Add(parameterFieldPea)

        '@Lentil int,
        Dim parameterLentil As SqlParameter = New SqlParameter("@Lentil", SqlDbType.Int)
        parameterLentil.Value = CInt(Me.ChkLentil.Checked)
        myCommand.Parameters.Add(parameterLentil)

        '@Lupin int,
        Dim parameterLupin As SqlParameter = New SqlParameter("@Lupin", SqlDbType.Int)
        parameterLupin.Value = CInt(Me.ChkLupin.Checked)
        myCommand.Parameters.Add(parameterLupin)

        '@Mungbean int,
        Dim parameterMungbean As SqlParameter = New SqlParameter("@Mungbean", SqlDbType.Int)
        parameterMungbean.Value = CInt(Me.ChkMungbean.Checked)
        myCommand.Parameters.Add(parameterMungbean)

        '@Vetch int,
        Dim parameterVetch As SqlParameter = New SqlParameter("@Vetch", SqlDbType.Int)
        parameterVetch.Value = CInt(Me.ChkVetch.Checked)
        myCommand.Parameters.Add(parameterVetch)

        '========================================================================
        ' Organisations
        '========================================================================

        '@Org_Pulse_Australia int,
        Dim parameterOrg_Pulse_Australia As SqlParameter = New SqlParameter("@Org_Pulse_Australia", SqlDbType.Int)
        parameterOrg_Pulse_Australia.Value = CInt(Me.ChkPulse_Australia.Checked)
        myCommand.Parameters.Add(parameterOrg_Pulse_Australia)

        '@Org_Pulse_Breading_Australia int,
        Dim parameterOrg_Pulse_Breading_Australia As SqlParameter = New SqlParameter("@Org_Pulse_Breading_Australia", SqlDbType.Int)
        parameterOrg_Pulse_Breading_Australia.Value = CInt(Me.ChkPulse_Breading.Checked)
        myCommand.Parameters.Add(parameterOrg_Pulse_Breading_Australia)

        '@Org_AMA int,
        Dim parameterOrg_AMA As SqlParameter = New SqlParameter("@Org_AMA", SqlDbType.Int)
        parameterOrg_AMA.Value = CInt(Me.ChkAMA.Checked)
        myCommand.Parameters.Add(parameterOrg_AMA)

        '@Org_VIC_DPI int,
        Dim parameterOrg_VIC_DPI As SqlParameter = New SqlParameter("@Org_VIC_DPI", SqlDbType.Int)
        parameterOrg_VIC_DPI.Value = CInt(Me.ChkVictoria_DPI.Checked)
        myCommand.Parameters.Add(parameterOrg_VIC_DPI)

        '@Org_GRDC_PUBLICATION int,
        Dim parameterOrg_GRDC_PUBLICATION As SqlParameter = New SqlParameter("@Org_GRDC_PUBLICATION", SqlDbType.Int)
        parameterOrg_GRDC_PUBLICATION.Value = CInt(Me.ChkGRDC_Publication.Checked)
        myCommand.Parameters.Add(parameterOrg_GRDC_PUBLICATION)

        '@Org_GRDC_Project int,
        Dim parameterOrg_GRDC_Project As SqlParameter = New SqlParameter("@Org_GRDC_Project", SqlDbType.Int)
        parameterOrg_GRDC_Project.Value = CInt(Me.ChkGRDC_Project.Checked)
        myCommand.Parameters.Add(parameterOrg_GRDC_Project)

        '@Org_Western_DAFWA int,
        Dim parameterOrg_Western_DAFWA As SqlParameter = New SqlParameter("@Org_Western_DAFWA", SqlDbType.Int)
        parameterOrg_Western_DAFWA.Value = CInt(Me.ChkWestern_DAFWA.Checked)
        myCommand.Parameters.Add(parameterOrg_Western_DAFWA)

        '@Org_INSW int,
        Dim parameterOrg_INSW As SqlParameter = New SqlParameter("@Org_INSW", SqlDbType.Int)
        parameterOrg_INSW.Value = CInt(Me.ChkNew_South_INSW.Checked)
        myCommand.Parameters.Add(parameterOrg_INSW)

        '@Org_Queensland_DEEDI int,
        Dim parameterOrg_Queensland_DEEDI As SqlParameter = New SqlParameter("@Org_Queensland_DEEDI", SqlDbType.Int)
        parameterOrg_Queensland_DEEDI.Value = CInt(Me.ChkQueensland_DPI.Checked)
        myCommand.Parameters.Add(parameterOrg_Queensland_DEEDI)

        '@Org_South_Australia int,
        Dim parameterOrg_South_Australia As SqlParameter = New SqlParameter("@Org_South_Australia", SqlDbType.Int)
        parameterOrg_South_Australia.Value = CInt(Me.ChkSouth_Australia.Checked)
        myCommand.Parameters.Add(parameterOrg_South_Australia)


        '========================================================================
        ' Organisations - Result Table
        '========================================================================

        '10..@Org_Result_Pulse_Australia int,
        Dim parameterOrg_Result_Pulse_Australia As SqlParameter = New SqlParameter("@Org_Result_Pulse_Australia", SqlDbType.Int)
        parameterOrg_Result_Pulse_Australia.Value = CInt(Me.Chk_Result_Pulse.Checked)
        myCommand.Parameters.Add(parameterOrg_Result_Pulse_Australia)

        '10..@Org_Result_PBA int,
        Dim parameterOrg_Result_PBA As SqlParameter = New SqlParameter("@Org_Result_PBA", SqlDbType.Int)
        parameterOrg_Result_PBA.Value = CInt(Me.Chk_Result_PBA.Checked)
        myCommand.Parameters.Add(parameterOrg_Result_PBA)

        '11..@Org_Result_AMA int,
        Dim parameterOrg_Result_AMA As SqlParameter = New SqlParameter("@Org_Result_AMA", SqlDbType.Int)
        parameterOrg_Result_AMA.Value = CInt(Me.Chk_Result_AMA.Checked)
        myCommand.Parameters.Add(parameterOrg_Result_AMA)

        '12..@Org_Result_VIC_DPI int,
        Dim parameterOrg_Result_VIC_DPI As SqlParameter = New SqlParameter("@Org_Result_VIC_DPI", SqlDbType.Int)
        parameterOrg_Result_VIC_DPI.Value = CInt(Me.Chk_Result_DPI_Vic.Checked)
        myCommand.Parameters.Add(parameterOrg_Result_VIC_DPI)

        '13..@Org_Result_GRDC_PUBLICATION int,
        Dim parameterOrg_Result_GRDC_PUBLICATION As SqlParameter = New SqlParameter("@Org_Result_GRDC_PUBLICATION", SqlDbType.Int)
        parameterOrg_Result_GRDC_PUBLICATION.Value = CInt(Me.Chk_Result_GRDC_Publ.Checked)
        myCommand.Parameters.Add(parameterOrg_Result_GRDC_PUBLICATION)

        '..@Org_Result_GRDC_Project int,
        Dim parameterOrg_Result_GRDC_Project As SqlParameter = New SqlParameter("@Org_Result_GRDC_Project", SqlDbType.Int)
        parameterOrg_Result_GRDC_Project.Value = CInt(Me.Chk_Result_GRDC_Project.Checked)
        myCommand.Parameters.Add(parameterOrg_Result_GRDC_Project)

        '15..@Org_Result_Western_DAFWA int,
        Dim parameterOrg_Result_Western_DAFWA As SqlParameter = New SqlParameter("@Org_Result_Western_DAFWA", SqlDbType.Int)
        parameterOrg_Result_Western_DAFWA.Value = CInt(Me.Chk_Result_DAFWA.Checked)
        myCommand.Parameters.Add(parameterOrg_Result_Western_DAFWA)

        '16..@Org_Result_INSW int,
        Dim parameterOrg_Result_INSW As SqlParameter = New SqlParameter("@Org_Result_INSW", SqlDbType.Int)
        parameterOrg_Result_INSW.Value = CInt(Me.Chk_Result_IINSW.Checked)
        myCommand.Parameters.Add(parameterOrg_Result_INSW)

        '17..@Org_Result_Queensland_DEEDI int,
        Dim parameterOrg_Result_Queensland_DEEDI As SqlParameter = New SqlParameter("@Org_Result_Queensland_DEEDI", SqlDbType.Int)
        parameterOrg_Result_Queensland_DEEDI.Value = CInt(Me.Chk_Result_DEEDI.Checked)
        myCommand.Parameters.Add(parameterOrg_Result_Queensland_DEEDI)

        '18..@Org_Result_SARDI int,
        Dim parameterOrg_Result_SARDI As SqlParameter = New SqlParameter("@Org_Result_SARDI", SqlDbType.Int)
        parameterOrg_Result_SARDI.Value = CInt(Me.Chk_Result_SARDI.Checked)
        myCommand.Parameters.Add(parameterOrg_Result_SARDI)

        '18..@Org_Result_Rural_SOl_SA int,
        Dim parameterOrg_Result_Rural_SOl_SA As SqlParameter = New SqlParameter("@Org_Result_Rural_SOl_SA", SqlDbType.Int)
        parameterOrg_Result_Rural_SOl_SA.Value = CInt(Me.Chk_Result_Rural_SA.Checked)
        myCommand.Parameters.Add(parameterOrg_Result_Rural_SOl_SA)

        '18..@Org_Result_PIRSA int,
        Dim parameterOrg_Result_PIRSA As SqlParameter = New SqlParameter("@Org_Result_PIRSA", SqlDbType.Int)
        parameterOrg_Result_PIRSA.Value = CInt(Me.Chk_Result_PIRSA.Checked)
        myCommand.Parameters.Add(parameterOrg_Result_PIRSA)


        '========================================================================
        ' Regions
        '========================================================================

        '@Region_Northern int,
        Dim parameterRegion_Northern As SqlParameter = New SqlParameter("@Region_Northern", SqlDbType.Int)
        parameterRegion_Northern.Value = CInt(Me.ChkNorthern_region.Checked)
        myCommand.Parameters.Add(parameterRegion_Northern)

        '@Region_Southern int,
        Dim parameterRegion_Southern As SqlParameter = New SqlParameter("@Region_Southern", SqlDbType.Int)
        parameterRegion_Southern.Value = CInt(Me.ChkSouthern_Region.Checked)
        myCommand.Parameters.Add(parameterRegion_Southern)

        '@Region_Western int,
        Dim parameterRegion_Western As SqlParameter = New SqlParameter("@Region_Western", SqlDbType.Int)
        parameterRegion_Western.Value = CInt(Me.ChkWestern_Region.Checked)
        myCommand.Parameters.Add(parameterRegion_Western)

        '========================================================================
        ' Category/ Topics
        '========================================================================
        '@Cat_Crop_Management int,
        Dim parameterCat_Crop_Management As SqlParameter = New SqlParameter("@Cat_Crop_Management", SqlDbType.Int)
        parameterCat_Crop_Management.Value = CInt(Me.ChkCrop_Management.Checked)
        myCommand.Parameters.Add(parameterCat_Crop_Management)

        '@Cat_Rotation_Planning int,
        Dim parameterCat_Rotation_Planning As SqlParameter = New SqlParameter("@Cat_Rotation_Planning", SqlDbType.Int)
        parameterCat_Rotation_Planning.Value = CInt(Me.ChkRotation_Planning.Checked)
        myCommand.Parameters.Add(parameterCat_Rotation_Planning)

        '@Cat_Gross_Margin int,
        'Dim parameterCat_Gross_Margin As SqlParameter = New SqlParameter("@Cat_Gross_Margin", SqlDbType.Int)
        'parameterCat_Gross_Margin.Value = CInt(Me.ChkGross_Margins.Checked)
        'myCommand.Parameters.Add(parameterCat_Gross_Margin)

        '@Cat_Variete int,
        Dim parameterCat_Variete As SqlParameter = New SqlParameter("@Cat_Variete", SqlDbType.Int)
        parameterCat_Variete.Value = CInt(Me.ChkVarietes.Checked)
        myCommand.Parameters.Add(parameterCat_Variete)

        '@Cat_Crop_Nutrition int,
        Dim parameterCat_Crop_Nutrition As SqlParameter = New SqlParameter("@Cat_Crop_Nutrition", SqlDbType.Int)
        parameterCat_Crop_Nutrition.Value = CInt(Me.ChkCrop_nutrition.Checked)
        myCommand.Parameters.Add(parameterCat_Crop_Nutrition)

        '@Cat_Crop_Establishment int,
        Dim parameterCat_Crop_Establishment As SqlParameter = New SqlParameter("@Cat_Crop_Establishment", SqlDbType.Int)
        parameterCat_Crop_Establishment.Value = CInt(Me.ChkCrop_Establishment.Checked)
        myCommand.Parameters.Add(parameterCat_Crop_Establishment)

        '@Cat_Weed_Management int,
        Dim parameterCat_Weed_Management As SqlParameter = New SqlParameter("@Cat_Weed_Management", SqlDbType.Int)
        parameterCat_Weed_Management.Value = CInt(Me.ChkWeed_Management.Checked)
        myCommand.Parameters.Add(parameterCat_Weed_Management)

        '@Cat_Disease_Management int,
        Dim parameterCat_Disease_Management As SqlParameter = New SqlParameter("@Cat_Disease_Management", SqlDbType.Int)
        parameterCat_Disease_Management.Value = CInt(Me.ChkDisease_Management.Checked)
        myCommand.Parameters.Add(parameterCat_Disease_Management)

        '@Cat_Insect_Management int,
        Dim parameterCat_Insect_Management As SqlParameter = New SqlParameter("@Cat_Insect_Management", SqlDbType.Int)
        parameterCat_Insect_Management.Value = CInt(Me.ChkInsect_Management.Checked)
        myCommand.Parameters.Add(parameterCat_Insect_Management)

        '@Cat_Harvest_Storage int,
        Dim parameterCat_Harvest_Storage As SqlParameter = New SqlParameter("@Cat_Harvest_Storage", SqlDbType.Int)
        parameterCat_Harvest_Storage.Value = CInt(Me.ChkHarvest_Storage.Checked)
        myCommand.Parameters.Add(parameterCat_Harvest_Storage)

        '@Cat_Marketing int,
        Dim parameterCat_Marketing As SqlParameter = New SqlParameter("@Cat_Marketing", SqlDbType.Int)
        parameterCat_Marketing.Value = CInt(Me.ChkMarketing.Checked)
        myCommand.Parameters.Add(parameterCat_Marketing)

        '@Cat_Pulse_Uses int,
        Dim parameterCat_Pulse_Uses As SqlParameter = New SqlParameter("@Cat_Pulse_Uses", SqlDbType.Int)
        parameterCat_Pulse_Uses.Value = CInt(Me.ChkPulse_Uses.Checked)
        myCommand.Parameters.Add(parameterCat_Pulse_Uses)

        '@Cat_Pulse_Update int,
        Dim parameterCat_Pulse_Update As SqlParameter = New SqlParameter("@Cat_Pulse_Update", SqlDbType.Int)
        parameterCat_Pulse_Update.Value = CInt(Me.ChkPulse_Update.Checked)
        myCommand.Parameters.Add(parameterCat_Pulse_Update)

        '@Cat_Pulse_Tech_Notes int,
        Dim parameterCat_Pulse_Tech_Notes As SqlParameter = New SqlParameter("@Cat_Pulse_Tech_Notes", SqlDbType.Int)
        parameterCat_Pulse_Tech_Notes.Value = CInt(Me.ChkPulse_Tech_Notes.Checked)
        myCommand.Parameters.Add(parameterCat_Pulse_Tech_Notes)

        ''@Publication varchar(100),
        'Dim parameterPublication As SqlParameter = New SqlParameter("@Publication", SqlDbType.VarChar, 100)
        '    parameterPublication.Value = Me.DDLPublicationType.SelectedItem.Text
        'myCommand.Parameters.Add(parameterPublication)

        '@Title varchar(200), 
        Dim parameterTitle As SqlParameter = New SqlParameter("@Title", SqlDbType.VarChar, 200)
        parameterTitle.Value = Me.TbTitle.Text
        myCommand.Parameters.Add(parameterTitle)

        '@Keywords varchar(1000)
        Dim parameterKeywords As SqlParameter = New SqlParameter("@Keywords", SqlDbType.VarChar, 1000)
        parameterKeywords.Value = Me.TbKeywords.Text
        myCommand.Parameters.Add(parameterKeywords)


        '@FileInKB varchar(25)
        Dim parameterFileInKB As SqlParameter = New SqlParameter("@FileInKB", SqlDbType.VarChar, 25)
        If CStr(Session("FileInKB")) = "" Then
            parameterFileInKB.Value = ""
        Else
            parameterFileInKB.Value = CStr(Session("FileInKB"))
        End If
        myCommand.Parameters.Add(parameterFileInKB)


        '@File_Name	varchar(1000),
        Dim parameterFile_Name As SqlParameter = New SqlParameter("@File_Name", SqlDbType.VarChar, 1000)
        If Session("FileUpload_Name") = "" Then
            parameterFile_Name.Value = ""
        Else
            parameterFile_Name.Value = Session("FileUpload_Name")
        End If
        myCommand.Parameters.Add(parameterFile_Name)

        '@URL varchar(300)
        Dim parameterURL As SqlParameter = New SqlParameter("@URL", SqlDbType.VarChar, 1000)
        If Me.TbURL.Text.Length <= 0 Then
            parameterURL.Value = ""
        Else
            parameterURL.Value = Me.TbURL.Text
        End If
        myCommand.Parameters.Add(parameterURL)

        '@RefNo varchar(25)
        Dim parameterRefNo As SqlParameter = New SqlParameter("@RefNo", SqlDbType.VarChar, 25)
        parameterRefNo.Value = Session("RefNO")
        myCommand.Parameters.Add(parameterRefNo)



        myConnection.Open()
        myCommand.ExecuteNonQuery()
        myConnection.Close()


    End Sub

    Protected Sub Insert_PublicationsA()

        '@UserID varchar(20),
        '@Cat_Gross_Margin int


        Dim myConnection As SqlConnection = New SqlConnection(ConfigurationManager.AppSettings("ConnectionString"))
        Dim myCommand As SqlCommand = New SqlCommand("Insert_PublicationsA", myConnection)
        ' Mark the Command as a SPROC
        myCommand.CommandType = CommandType.StoredProcedure
        ' Add Parameters to SPROC

        '@UserID as varchar(20),
        Dim parameterUserID As SqlParameter = New SqlParameter("@UserID", SqlDbType.VarChar, 30)
        parameterUserID.Value = Session("UserID")
        myCommand.Parameters.Add(parameterUserID)

        '@Cat_Gross_Margin int,
        Dim parameterCat_Gross_Margin As SqlParameter = New SqlParameter("@Cat_Gross_Margin", SqlDbType.Int)
        parameterCat_Gross_Margin.Value = CInt(Me.ChkGross_Margins.Checked)
        myCommand.Parameters.Add(parameterCat_Gross_Margin)

        myConnection.Open()
        myCommand.ExecuteNonQuery()
        myConnection.Close()



    End Sub


    ''' <summary>
    ''' Run validation on each control as required
    ''' </summary>

    Private Function ValidateInput() As Boolean

        'First check that all the "required" fields have a value.
        If Not CheckRequired() Then
            Return False
        Else
            If Not CheckValidation() Then 'Second ensure that each field meets validation criteria
                Return False
            Else

                Return True
            End If
        End If

    End Function

    Private Function CheckRequired() As Boolean

        'Check for the crop type
        If Me.ChkAdBean.Checked = False And Me.ChkChickPea.Checked = False And Me.chkFabaBean.Checked = False And Me.chkFieldPea.Checked = False And Me.ChkLentil.Checked = False And Me.ChkLupin.Checked = False And Me.ChkMungbean.Checked = False And Me.ChkVetch.Checked = False Then
            Say("Please !! Select atleast one Crop !!")
            Return False
        End If

        'Check for the Organisation
        If Me.ChkPulse_Australia.Checked = False And Me.ChkPulse_Breading.Checked = False And Me.ChkAMA.Checked = False And Me.ChkVictoria_DPI.Checked = False And Me.ChkGRDC_Publication.Checked = False And Me.ChkGRDC_Project.Checked = False And Me.ChkWestern_DAFWA.Checked = False And Me.ChkNew_South_INSW.Checked = False And Me.ChkQueensland_DPI.Checked = False And Me.ChkSouth_Australia.Checked = False Then
            Say("Please !! Select atleast one Organisation !!")
            Return False
        End If

        'Check for the Regions
        If Me.ChkNorthern_region.Checked = False And Me.ChkSouthern_Region.Checked = False And Me.ChkWestern_Region.Checked = False Then
            Say("Please !! Select atleast one Region !!")
            Return False
        End If

        'Check for the Category
        If Me.ChkCrop_Management.Checked = False And Me.ChkRotation_Planning.Checked = False And Me.ChkGross_Margins.Checked = False And Me.ChkVarietes.Checked = False And Me.ChkCrop_nutrition.Checked = False And Me.ChkCrop_Establishment.Checked = False And Me.ChkWeed_Management.Checked = False And Me.ChkDisease_Management.Checked = False And Me.ChkInsect_Management.Checked = False And Me.ChkHarvest_Storage.Checked = False And Me.ChkMarketing.Checked = False And Me.ChkPulse_Uses.Checked = False And Me.ChkPulse_Update.Checked = False And Me.ChkPulse_Tech_Notes.Checked = False Then
            Say("Please !! Select atleast one Category/Topic !!")
            Return False
        End If


        'If Me.DDLPublicationType.SelectedItem.Text.Length <= 0 Then
        '  Say("Please !! select Publication Type from Drop down menu !! ")
        '  Return False
        'End If

        If Me.TbTitle.Text.Length <= 0 Then
            Say("Please, Enter a Title for Publication !!")
            Return False
        End If


        Return True

    End Function

    Private Function CheckValidation() As Boolean

        If Me.TbURL.Text.Length <= 0 Then

            Try
                Dim TheFile As FileInfo = New FileInfo(MapPath(".") & "\pdf\" & Session("FileUpload_Name"))
                If TheFile.Exists Then

                    Return True
                Else

                    Say("Please Upload Publication File before submiting Publication data")
                    Return False

                End If

            Catch ex As FileNotFoundException

                lblStatus.Text += ex.Message
            Catch ex As Exception

                lblStatus.Text += ex.Message
            End Try

        Else

            Return True

        End If



    End Function


    'Protected Sub BtnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnDelete.Click


    '  Try

    '    Dim TheFile As FileInfo = New FileInfo(MapPath(".") & "\" & txtFile.Text)
    '    If TheFile.Exists Then

    '    File.Delete(MapPath(".") & "\" & txtFile.Text)
    '    Else

    '    Throw New FileNotFoundException()
    '    End If

    '  Catch ex As FileNotFoundException

    '    lblStatus.Text += ex.Message
    '  Catch ex As Exception

    '    lblStatus.Text += ex.Message
    '  End Try

    'End Sub

    Protected Sub BtnBack_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnBack.Click
        Response.Redirect("Admin_Search_Publications.aspx")
    End Sub

    Protected Sub ChkAll_Organisations_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ChkAll_Organisations.CheckedChanged

        If Me.ChkAll_Organisations.Checked = True Then

            Me.ChkPulse_Australia.Checked = True
            Me.ChkPulse_Breading.Checked = True
            Me.ChkAMA.Checked = True
            Me.ChkVictoria_DPI.Checked = True
            Me.ChkGRDC_Publication.Checked = True
            Me.ChkGRDC_Project.Checked = True
            Me.ChkWestern_DAFWA.Checked = True
            Me.ChkNew_South_INSW.Checked = True
            Me.ChkQueensland_DPI.Checked = True
            Me.ChkSouth_Australia.Checked = True


        ElseIf Me.ChkAll_Organisations.Checked = False Then

            Me.ChkPulse_Australia.Checked = False
            Me.ChkPulse_Breading.Checked = False
            Me.ChkAMA.Checked = False
            Me.ChkVictoria_DPI.Checked = False
            Me.ChkGRDC_Publication.Checked = False
            Me.ChkGRDC_Project.Checked = False
            Me.ChkWestern_DAFWA.Checked = False
            Me.ChkNew_South_INSW.Checked = False
            Me.ChkQueensland_DPI.Checked = False
            Me.ChkSouth_Australia.Checked = False

        End If

    End Sub

    Protected Sub ChkAll_Regions_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ChkAll_Regions.CheckedChanged

        If Me.ChkAll_Regions.Checked = True Then

            Me.ChkNorthern_region.Checked = True
            Me.ChkSouthern_Region.Checked = True
            Me.ChkWestern_Region.Checked = True



        ElseIf Me.ChkAll_Regions.Checked = False Then

            Me.ChkNorthern_region.Checked = False
            Me.ChkSouthern_Region.Checked = False
            Me.ChkWestern_Region.Checked = False

        End If


    End Sub


    Protected Sub ChkAll_Category_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ChkAll_Category.CheckedChanged

        If Me.ChkAll_Category.Checked = True Then

            Me.ChkCrop_Management.Checked = True
            Me.ChkRotation_Planning.Checked = True
            Me.ChkGross_Margins.Checked = True
            Me.ChkVarietes.Checked = True
            Me.ChkCrop_nutrition.Checked = True
            Me.ChkCrop_Establishment.Checked = True
            Me.ChkWeed_Management.Checked = True
            Me.ChkDisease_Management.Checked = True
            Me.ChkInsect_Management.Checked = True
            Me.ChkHarvest_Storage.Checked = True
            Me.ChkMarketing.Checked = True
            Me.ChkPulse_Uses.Checked = True
            Me.ChkPulse_Update.Checked = True
            Me.ChkPulse_Tech_Notes.Checked = True

        ElseIf Me.ChkAll_Category.Checked = False Then

            Me.ChkCrop_Management.Checked = False
            Me.ChkRotation_Planning.Checked = False
            Me.ChkGross_Margins.Checked = False
            Me.ChkVarietes.Checked = False
            Me.ChkCrop_nutrition.Checked = False
            Me.ChkCrop_Establishment.Checked = False
            Me.ChkWeed_Management.Checked = False
            Me.ChkDisease_Management.Checked = False
            Me.ChkInsect_Management.Checked = False
            Me.ChkHarvest_Storage.Checked = False
            Me.ChkMarketing.Checked = False
            Me.ChkPulse_Uses.Checked = False
            Me.ChkPulse_Update.Checked = False
            Me.ChkPulse_Tech_Notes.Checked = False

        End If

    End Sub

    Protected Sub Chk_Result_All_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Chk_Result_All.CheckedChanged

        If Me.Chk_Result_All.Checked = True Then

            Me.Chk_Result_Pulse.Checked = True
            Me.Chk_Result_AMA.Checked = True
            Me.Chk_Result_DPI_Vic.Checked = True
            Me.Chk_Result_GRDC_Publ.Checked = True
            Me.Chk_Result_GRDC_Project.Checked = True
            Me.Chk_Result_DAFWA.Checked = True
            Me.Chk_Result_IINSW.Checked = True
            Me.Chk_Result_DEEDI.Checked = True
            Me.Chk_Result_SARDI.Checked = True
            Me.Chk_Result_Rural_SA.Checked = True
            Me.Chk_Result_PIRSA.Checked = True

        ElseIf Me.Chk_Result_All.Checked = False Then

            Me.Chk_Result_Pulse.Checked = False
            Me.Chk_Result_AMA.Checked = False
            Me.Chk_Result_DPI_Vic.Checked = False
            Me.Chk_Result_GRDC_Publ.Checked = False
            Me.Chk_Result_GRDC_Project.Checked = False
            Me.Chk_Result_DAFWA.Checked = False
            Me.Chk_Result_IINSW.Checked = False
            Me.Chk_Result_DEEDI.Checked = False
            Me.Chk_Result_SARDI.Checked = False
            Me.Chk_Result_Rural_SA.Checked = False
            Me.Chk_Result_PIRSA.Checked = False

        End If


    End Sub


End Class

As i said it all worked until i tried to add in the "Insert_PublicationsA()". I originally just tried adding the extra code into "Insert_Publications()" but got the error:

Exception Details: System.Data.SqlClient.SqlException: Procedure or function Insert_Publications has too many arguments specified.

Any help would be great.
Thanks

3
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by bill51
0

Have you adjusted the sp to take account of the additional fields you are inserting? The final error message you have means that there is discrepancy between the parameters you are trying to pass and the parameters defined in the sp definition. Or if you created an amended sp Insert_PublicationsA Insert_Publications you not amended your code to call the new procedure

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.