rcowen00
asked on
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
ASKER
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
Yes. So there is no error? Change
cmd.ExecuteScalar()
to
cmd.ExecuteNonQuery()
cmd.ExecuteScalar()
to
cmd.ExecuteNonQuery()
ASKER
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
ASKER
CodeCruiser,
Could the problem be the form tag? I
<form id="Form1" runat="server" action="#" onsubmit="showLocation(); return false;">
Could the problem be the form tag? I
<form id="Form1" runat="server" action="#" onsubmit="showLocation(); return false;">
May be. Did you put a break point in code to see if its executing. Why do you have in form?
ASKER
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.
ASKER
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
ASKER
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry, can you clarify? Thank you.
The form tag that you showed in http:#37299812 that could be a problem.
try removing "return false;" from onsubmit attribute
ASKER
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" />
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"
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try adding a
Catch ex as exception
msgbox ex.tostring()