activeXobject connection...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sandra

    activeXobject connection...

    Hi All,

    What is wrong with my code....The function "function ValidaProdutos( )"
    is not working....I need to execute the procedure to insert data in a
    Database.... What can I do to have this code working.... I don't get
    error line, but nothing happen in my database.... I think the
    connection is not right.... Could anyone give a sample code on how to
    do that.....

    thank you very much....

    <html>
    <head>
    <title>Untitl ed Document</title>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    </head>
    <script language='JavaS cript'>

    function ValidaProdutos( )
    {
    var Qtd_Solic;
    var Cod_Presente;
    valor = 0;
    var SQL;

    var connString = "Provider=SQLOL EDB.1;Persist Security
    Info=False;User ID=sa;Data Source="CLESIO ";Initial Catalog=DBO_CRE ";
    var ObjConn = new ActiveXObject(" ADODB.CONNECTIO N");
    ObjConn.open( connString);
    var objRs = new ActiveXObject(" ADODB.CONNECTIO N");

    if( document.all['txtQTD'].length )
    {
    for(i=0; i < document.all['txtQTD'].length ; i++)
    {
    if( document.all['txtQTD'][i].value != '' &&
    document.all['txtQTD'][i].value > 0)
    {
    Qtd_Solic = document.all['txtQTD'][i].value
    Cod_Presente = document.all['Cod_Presente'][i].value

    SQL = "Exec dbo_CRE.dbo.sp_ IN_0029T " + session("Cod_Ls Padrao") +
    "," + document.all['Cod_Presente'][i].value + "," +
    document.all['txtQTD'][i].value + "," +
    document.all['txtQTD'][i].value + "," + session("Cod_Fu nc");

    objRs = ObjConn.execute (SQL);

    }
    }

    }
    </script>

    <body bgcolor="#FFFFF F" text="#000000">
    ..
    ..
    .. more code here....
    ..
    ..
    <form name="form" method="post" action="">

    <table width=80%" border="0">
    <tr valign="bottom" >
    <td width="10%" class="LabelAsp " nowrap bgcolor= '#007EBB'>
    <div align="center"> <font color="#FFFFFF" >Código
    </font></div>
    </td>
    <td width="50%" class="LabelAsp " bgcolor= '#007EBB'>
    <div align="center"> <font color="#FFFFFF" >Descrição
    </font></div>
    </td>
    <td width="10%" class="LabelAsp " bgcolor= '#007EBB'>
    <div align="center"> <font color="#FFFFFF" >Valor</font> </div>
    </td>
    <td width="10%" class="LabelAsp " nowrap align="left" bgcolor=
    '#007EBB'>
    <div align="center"> <font color="#FFFFFF" >Qtd.</font>
    </div>
    </td>
    </tr>


    <%

    while Not retorno.Eof

    %>
    <tr>
    <td bgcolor="#DCECF 5" width="10%" height="20" class="LabelAsp "
    name="Cod_Prese nte"><%=retorno ("COD_PRESENTE" )%></td>
    <input type="hidden" name="Cod_Prese nte" size="3" maxlength="3"
    value="<%=retor no("COD_PRESENT E")%>">
    <td bgcolor="#DCECF 5" width="50%" class="LabelAsp "
    name="Desc_Pres ente" maxlenght="20"> <%=retorno("DSC _PRESENTE")%></td>
    <td bgcolor="#DCECF 5" width="10%" height="20" class="LabelAsp "
    name="Valor_Pre sente"><%=retor no("VAL_PRC_UNI T")%></td>
    <td bgcolor="#DCECF 5" width="10%">
    <input type="text" name="txtQTD" size="3" maxlength="3"
    value="" onKeyUp="JavaSc ript:ValidaNumb er();">
    </td>
    </tr>
    <%
    retorno.MoveNex t

    Wend
    retorno.close
    Set retorno = Nothing
    cnSQL.close
    Set cnSQL = Nothing
    %>
    </table>
    <input type="submit" name="Submit3" value="Incluir"
    onclick="Valida Produtos
    ();return false;">
    </form>
  • Martin Honnen

    #2
    Re: activeXobject connection...



    Sandra wrote:
    [color=blue]
    > What is wrong with my code....The function "function ValidaProdutos( )"
    > is not working....I need to execute the procedure to insert data in a
    > Database.... What can I do to have this code working.... I don't get
    > error line, but nothing happen in my database.... I think the
    > connection is not right.... Could anyone give a sample code on how to
    > do that.....[/color]

    [color=blue]
    > <html>
    > <head>
    > <title>Untitl ed Document</title>
    > <meta http-equiv="Content-Type" content="text/html;
    > charset=iso-8859-1">
    > </head>
    > <script language='JavaS cript'>
    >
    > function ValidaProdutos( )
    > {
    > var Qtd_Solic;
    > var Cod_Presente;
    > valor = 0;
    > var SQL;
    >
    > var connString = "Provider=SQLOL EDB.1;Persist Security
    > Info=False;User ID=sa;Data Source="CLESIO ";Initial Catalog=DBO_CRE ";
    > var ObjConn = new ActiveXObject(" ADODB.CONNECTIO N");[/color]

    This is client side JavaScript, are you sure you want to store the data
    in the data base with client side JavaScript??
    Your code further below indicates you are using ASP with VBScript thus I
    strongly suggest to use ASP to store data in the database.
    http://www.aspfaq.com/ should help with sample ASP code.

    --

    Martin Honnen


    Comment

    • Sandra Mota

      #3
      Re: activeXobject connection...



      Hi Martin Honnen,

      Thank you for your answer, I would like to use VBScript, but I don´t
      know how do to that, since I need to check if I have more than one item
      in the screen and check if the "txtQTD" has value or not..... Could you
      help me on that? Is there any command in VBScript similar to .lenght in
      Javascript?

      thanks again
      Sandra

      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Martin Honnen

        #4
        Re: activeXobject connection...



        Sandra Mota wrote:[color=blue]
        > Thank you for your answer, I would like to use VBScript, but I don´t
        > know how do to that, since I need to check if I have more than one item
        > in the screen and check if the "txtQTD" has value or not..... Could you
        > help me on that? Is there any command in VBScript similar to .lenght in
        > Javascript?[/color]

        I suggested to use ASP, that is server side scripting, to store values
        in a data base. In ASP's object model there are a lot of collections like
        Request.Form
        or
        Request.QuerySt ring
        and all those collections have a property named
        Count
        to check the length of the collection whether you use JavaScript or
        VBScript.
        I think you thoroughly confuse client side and server side scripting, as
        you have ASP go for server side scripting and process the submitted form
        data there and store it in your data base. As suggested
        This is a default index page for a new domain.

        is a good place to start.

        --

        Martin Honnen


        Comment

        Working...