Stored Procedure not triggering

I have a button that should be firing the code below but it isn't doing anything.  No errors, nothing.  What am I doing wrong.  Thanks
Protected Sub btnSaveCompEvalProperty_Click(sender As Object, e As EventArgs) Handles btnSaveCompEvalProperty.Click
        UpdateVendorPropertySection()
    End Sub

    Private Sub UpdateVendorPropertySection()

        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
        Try
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.CompEvalPropertyUpdate"
            cmd.Parameters.Add("@Listed12Months", Data.SqlDbType.VarChar).Value = txtListed12Months.Text
            cmd.Parameters.Add("@Sold12Months", Data.SqlDbType.VarChar).Value = txtSold12Months.Text
            Dim iUserId As New Guid(Membership.GetUser(My.User.Name).ProviderUserKey.ToString())
            cmd.Parameters.Add("@UserKey", Data.SqlDbType.VarChar).Value = iUserId.ToString
            cnn.Open()
            cmd.ExecuteScalar()
           
        Finally
            cnn.Close()
        End Try
    End Sub

Open in new window

rcowen00Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
How do you know there is no error?

Try adding a

Catch ex as exception
       msgbox ex.tostring()
0
rcowen00Author Commented:
Still nothing, did I put it in the correct location?
Protected Sub btnSaveCompEvalProperty_Click(sender As Object, e As EventArgs) Handles btnSaveCompEvalProperty.Click
        UpdateVendorPropertySection()
    End Sub

    Private Sub UpdateVendorPropertySection()

        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
        Try
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.CompEvalPropertyUpdate"
            cmd.Parameters.Add("@Listed12Months", Data.SqlDbType.VarChar).Value = txtListed12Months.Text
            cmd.Parameters.Add("@Sold12Months", Data.SqlDbType.VarChar).Value = txtSold12Months.Text
            Dim iUserId As New Guid(Membership.GetUser(My.User.Name).ProviderUserKey.ToString())
            cmd.Parameters.Add("@UserKey", Data.SqlDbType.VarChar).Value = iUserId.ToString
            cnn.Open()
            cmd.ExecuteScalar()
        Catch ex As Exception
            MsgBox(ex.ToString())
        Finally
            cnn.Close()

        End Try
    End Sub

Open in new window

0
CodeCruiserCommented:
Yes. So there is no error? Change

cmd.ExecuteScalar()

to

cmd.ExecuteNonQuery()
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

rcowen00Author Commented:
Still nothing
Protected Sub btnSaveCompEvalProperty_Click(sender As Object, e As EventArgs) Handles btnSaveCompEvalProperty.Click
        UpdateVendorPropertySection()
    End Sub

    Private Sub UpdateVendorPropertySection()

        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
        Try
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.CompEvalPropertyUpdate"
            cmd.Parameters.Add("@Listed12Months", Data.SqlDbType.VarChar).Value = txtListed12Months.Text
            cmd.Parameters.Add("@Sold12Months", Data.SqlDbType.VarChar).Value = txtSold12Months.Text
            Dim iUserId As New Guid(Membership.GetUser(My.User.Name).ProviderUserKey.ToString())
            cmd.Parameters.Add("@UserKey", Data.SqlDbType.VarChar).Value = iUserId.ToString
            cnn.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.ToString())
        Finally
            cnn.Close()

        End Try
    End Sub

Open in new window

0
rcowen00Author Commented:
CodeCruiser,

Could the problem be the form tag?  I

 <form id="Form1" runat="server" action="#" onsubmit="showLocation(); return false;">
0
CodeCruiserCommented:
May be. Did you put a break point in code to see if its executing. Why do you have in form?
0
rcowen00Author Commented:
That is what is required to calculate distance between two properties using google maps.  I also found that I did not in the page load, but I thought I was triggering it from the Save button, not from postback.
0
rcowen00Author Commented:
Ok, so I am getting closer since the field is being zero'd out on open.  Which means (I believe) I am calling it from the wrong place.  Any suggestions?  Thank you.
Public Class CompEvalProperty
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim OrdersProductKey As String
        If (Request.QueryString("OrderProductKey") <> Nothing) Then
            OrdersProductKey = Request.QueryString("OrderProductKey")

            If Not IsPostBack Then
                LoadVendorPropertySection(Convert.ToString(Request.QueryString("OrderProductKey")))
            End If
            UpdateVendorPropertySection()
        End If
    End Sub

    Private Sub LoadVendorPropertySection(ByVal OrdersProductKey As String)
        Dim VendorId As String
        VendorId = Request.QueryString("VendorId")

        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
        Try
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.GetOrdersProductByOrdersProductKey"
            cmd.Parameters.Add("@OrdersProductKey", Data.SqlDbType.VarChar).Value = OrdersProductKey
            cmd.Parameters.Add("@VendorId", Data.SqlDbType.VarChar).Value = VendorId
            Dim iUserId As New Guid(Membership.GetUser(My.User.Name).ProviderUserKey.ToString())
            cnn.Open()
            Dim dr As System.Data.SqlClient.SqlDataReader = cmd.ExecuteReader
            dr.Read()
            If dr.HasRows Then
                If Not IsDBNull(dr("LoanNumber")) Then txtLoanNumber.Text = dr("LoanNumber")
                If Not IsDBNull(dr("ReportEnteredDate")) Then txtDateEntered.Text = dr("ReportEnteredDate")
                If Not IsDBNull(dr("SubjectParcelNumber")) Then txtParcelNumber.Text = dr("SubjectParcelNumber")
                txtOwnerName.Text = dr("OwnerName")
                txtAddr1.Text = dr("PropAddr1")
                txtAddr2.Text = dr("PropAddr2")
                txtCity.Text = dr("PropCity")
                txtState.Text = dr("PropState")
                txtZip.Text = dr("PropZip")
                txtVendorCompanyName.Text = dr("VendorCompanyName")
                txtVendorName.Text = dr("VendorName")
                txtVendorPhone.Text = dr("VendorBusPhone")
                txtVendorFax.Text = dr("VendorFax")
                txtVendorEmail.Text = dr("VendorEmail")
                txtExperienceYear.Text = dr("YrsExp")
                address1.Text = dr("VendorAddrDistance")
                address2.Text = dr("SubjectAddrDistance")
                If Not IsDBNull(dr("BrokerSoldNumber")) Then txtSold12Months.Text = dr("BrokerSoldNumber")
                If Not IsDBNull(dr("BrokerListedNumber")) Then txtListed12Months.Text = dr("BrokerListedNumber")
            End If
        Finally
            cnn.Close()
        End Try
    End Sub

    Protected Sub btnInsertBrokerDistance_Click(sender As Object, e As EventArgs) Handles btnInsertBrokerDistance.Click
        BrokerDistCalcInsert()
    End Sub
    Private Sub BrokerDistCalcInsert()
        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
        Try
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.BrokerDistCalcInsert"
            txtBrokerDistCalc.Text = hidBrokerDistCalc.Value
            cmd.Parameters.Add("@BrokerDistCalc", Data.SqlDbType.VarChar).Value = txtBrokerDistCalc.ToString
            cmd.Parameters.Add("@OrdersProductKey" = Request.QueryString("OrderProductKey"))
            Dim iUserId As New Guid(Membership.GetUser(My.User.Name).ProviderUserKey.ToString())
            cmd.Parameters.Add("@UserKey", Data.SqlDbType.VarChar).Value = iUserId.ToString
            cnn.Open()
            Dim dr As Data.SqlClient.SqlDataReader = cmd.ExecuteReader
            dr.Read()
        Finally
            cnn.Close()

        End Try
    End Sub

    Protected Sub btnCloseBrokerDistance_Click(sender As Object, e As EventArgs) Handles btnCloseBrokerDistance.Click
        pnlCalcBrokerDistance.Visible = False
    End Sub

Open in new window

0
rcowen00Author Commented:
I still can't figure out why the SP is not firing.  Any help is appreciated.  Thank you.
Public Class CompEvalProperty
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim OrdersProductKey As String
        If (Request.QueryString("OrderProductKey") <> Nothing) Then
            OrdersProductKey = Request.QueryString("OrderProductKey")
            
            If Not IsPostBack Then
                LoadVendorPropertySection(Convert.ToString(Request.QueryString("OrderProductKey")))

            End If

        End If
    End Sub

    Private Sub LoadVendorPropertySection(ByVal OrdersProductKey As String)
        Dim VendorId As String
        VendorId = Request.QueryString("VendorId")

        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
        Try
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.GetOrdersProductByOrdersProductKey"
            cmd.Parameters.Add("@OrdersProductKey", Data.SqlDbType.VarChar).Value = OrdersProductKey
            cmd.Parameters.Add("@VendorId", Data.SqlDbType.VarChar).Value = VendorId
            Dim iUserId As New Guid(Membership.GetUser(My.User.Name).ProviderUserKey.ToString())
            cnn.Open()
            Dim dr As System.Data.SqlClient.SqlDataReader = cmd.ExecuteReader
            dr.Read()
            If dr.HasRows Then
                If Not IsDBNull(dr("LoanNumber")) Then txtLoanNumber.Text = dr("LoanNumber")
                If Not IsDBNull(dr("ReportEnteredDate")) Then txtDateEntered.Text = dr("ReportEnteredDate")
                If Not IsDBNull(dr("SubjectParcelNumber")) Then txtParcelNumber.Text = dr("SubjectParcelNumber")
                txtOwnerName.Text = dr("OwnerName")
                txtAddr1.Text = dr("PropAddr1")
                txtAddr2.Text = dr("PropAddr2")
                txtCity.Text = dr("PropCity")
                txtState.Text = dr("PropState")
                txtZip.Text = dr("PropZip")
                txtVendorCompanyName.Text = dr("VendorCompanyName")
                txtVendorName.Text = dr("VendorName")
                txtVendorPhone.Text = dr("VendorBusPhone")
                txtVendorFax.Text = dr("VendorFax")
                txtVendorEmail.Text = dr("VendorEmail")
                txtExperienceYear.Text = dr("YrsExp")
                address1.Text = dr("VendorAddrDistance")
                address2.Text = dr("SubjectAddrDistance")
                If Not IsDBNull(dr("BrokerSoldNumber")) Then txtSold12Months.Text = dr("BrokerSoldNumber")
                If Not IsDBNull(dr("BrokerListedNumber")) Then txtListed12Months.Text = dr("BrokerListedNumber")
            End If
        Finally
            cnn.Close()
        End Try
    End Sub

    Protected Sub btnInsertBrokerDistance_Click(sender As Object, e As EventArgs) Handles btnInsertBrokerDistance.Click

    End Sub
    Private Sub BrokerDistCalcInsert()
        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
        Try
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.BrokerDistCalcInsert"
            txtBrokerDistCalc.Text = hidBrokerDistCalc.Value
            cmd.Parameters.Add("@BrokerDistCalc", Data.SqlDbType.VarChar).Value = txtBrokerDistCalc.ToString
            cmd.Parameters.Add("@OrdersProductKey" = Request.QueryString("OrderProductKey"))
            Dim iUserId As New Guid(Membership.GetUser(My.User.Name).ProviderUserKey.ToString())
            cmd.Parameters.Add("@UserKey", Data.SqlDbType.VarChar).Value = iUserId.ToString
            cnn.Open()
            Dim dr As Data.SqlClient.SqlDataReader = cmd.ExecuteReader
            dr.Read()
        Finally
            cnn.Close()

        End Try
    End Sub

    Protected Sub btnCloseBrokerDistance_Click(sender As Object, e As EventArgs) Handles btnCloseBrokerDistance.Click
        pnlCalcBrokerDistance.Visible = False
    End Sub

   

    Private Sub UpdateVendorPropertySection()

        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
        Try
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.CompEvalPropertyUpdate"
            cmd.Parameters.Add("@OrdersProductKey", Data.SqlDbType.Int).Value = Request.QueryString("OrderProductKey")
            cmd.Parameters.Add("@Listed12Months", Data.SqlDbType.VarChar).Value = txtListed12Months.Text
            cmd.Parameters.Add("@Sold12Months", Data.SqlDbType.VarChar).Value = txtSold12Months.Text
            Dim iUserId As New Guid(Membership.GetUser(My.User.Name).ProviderUserKey.ToString())
            cmd.Parameters.Add("@UserId", Data.SqlDbType.VarChar).Value = iUserId.ToString
            cnn.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.ToString())
            Dim sRedirect As String = "GeneralMarketConditions.aspx?OrdersProduct=1&VendorId=cdd7f9d3-2ee6-489c-bd92-ad0b3735c7da"
            Response.Redirect(sRedirect)
        Finally
            cnn.Close()

        End Try
    End Sub

    Protected Sub btnSaveCompEvalProperty_Click(sender As Object, e As EventArgs) Handles btnSaveCompEvalProperty.Click
        UpdateVendorPropertySection()

    End Sub
End Class

Open in new window

0
CodeCruiserCommented:
Did you remove that form configuration of onsubmit?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rcowen00Author Commented:
Sorry, can you clarify?  Thank you.
0
CodeCruiserCommented:
The form tag that you showed in http:#37299812 that could be a problem.
0
dejaanbuCommented:
try removing  "return false;" from onsubmit attribute
0
rcowen00Author Commented:
dejaanbu- that did not change anything

codecruiser- If I remove the onsubmit entirely, it works.  But now the javascript to calculate the distance is not working.  How do I initiate the javascript when the user clicks?

  <asp:Button ID="btnCalcBrokerDistance" runat="server" Text="Calculate Broker Distance" />
0
dejaanbuCommented:
u can call it in button's Onclientclick event.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.