activeXobject connection...

S

Sandra

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>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<script language='JavaScript'>

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

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

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

SQL = "Exec dbo_CRE.dbo.sp_IN_0029T " + session("Cod_LsPadrao") +
"," + document.all['Cod_Presente'].value + "," +
document.all['txtQTD'].value + "," +
document.all['txtQTD'].value + "," + session("Cod_Func");

objRs = ObjConn.execute(SQL);

}
}

}
</script>

<body bgcolor="#FFFFFF" 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="#DCECF5" width="10%" height="20" class="LabelAsp"
name="Cod_Presente"><%=retorno("COD_PRESENTE")%></td>
<input type="hidden" name="Cod_Presente" size="3" maxlength="3"
value="<%=retorno("COD_PRESENTE")%>">
<td bgcolor="#DCECF5" width="50%" class="LabelAsp"
name="Desc_Presente" maxlenght="20"><%=retorno("DSC_PRESENTE")%></td>
<td bgcolor="#DCECF5" width="10%" height="20" class="LabelAsp"
name="Valor_Presente"><%=retorno("VAL_PRC_UNIT")%></td>
<td bgcolor="#DCECF5" width="10%">
<input type="text" name="txtQTD" size="3" maxlength="3"
value="" onKeyUp="JavaScript:ValidaNumber();">
</td>
</tr>
<%
retorno.MoveNext

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

Martin Honnen

Sandra said:
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.....

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

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

var connString = "Provider=SQLOLEDB.1;Persist Security
Info=False;User ID=sa;Data Source="CLESIO ";Initial Catalog=DBO_CRE";
var ObjConn = new ActiveXObject("ADODB.CONNECTION");

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.
 
S

Sandra Mota

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
 
M

Martin Honnen

Sandra said:
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?

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.QueryString
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
http://www.aspfaq.com/
is a good place to start.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top