Executescalar it's not executed RRS feed

  • Question

  • User601688711 posted

    Hi, I'm doing a pge method. Inside of it I make a query and a executescalar. All seems to work ok, I can access (debug) to the page method without problems. The problem arrives when the page method arrives to the executescalar, then appears an exclamation mark at the left on the line over the red circle (shows where the stop it's made). If I pass the mouse over the exclamation appear next message:

    En IntroducirBD.aspx.vb, line 618 carácter 17 ('Web_Puntech_v2.IntroducirBD.DeshabilitarDias(String)') en curso 'WebDev.WebServer40.EXE'

    When I'm debugging and stops on the line I can press F5, at last it get out of the function but the alert error (should be thrown since the JQuery call) doesn't appear.

    Page Method:

        <WebMethod()> _
        Public Shared Function DeshabilitarDias(ByVal fechabien As String) As String
                Dim fech As Date = Date.Parse(fechabien)
                Dim cadenaConexion As String = ConfigurationManager.ConnectionStrings("MiConexion").ConnectionString
                Dim cnn = New SqlConnection(cadenaConexion)
                Dim sentenciafestivos As New Data.SqlClient.SqlCommand("SELECT COUNT (fecha_fest) FROM fechas_festivos WHERE fecha_fest = @fechajs", cnn)
                sentenciafestivos.Parameters.AddWithValue("@fechajs", fech)
                Dim count As Integer = sentenciafestivos.ExecuteScalar()
                If count = 0 Then 'No es festivo'
                    Return "0"
                Else 'Es festivo'
                    Return "1"
                End If
            Catch ex As Exception
                Return "excp"
            End Try
        End Function

    JQuery Call

                    function diasdefiesta(date) {
                        var fechabien = date.getDate() + '-' + date.getMonth() + '-' + date.getFullYear();
                        var val;
                            type: "POST",
                            contentType: "application/json; charset=utf-8",
                            data: "{ fechabien: '" + fechabien + "'}",
                            url: 'IntroducirBD.aspx/DeshabilitarDias',
                            dataType: "json",
                            success: function (data) {
                                val = data;
                            error: function (e) {
                        return val;

    Any idea what's happenning? Thanks in advance

    Tuesday, September 13, 2011 4:56 AM


  • User-513735053 posted

    Where are you Openning Your Connection.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 13, 2011 5:15 AM