For Programmers: Free Programming Magazines  


Home > Archive > ASP > February 2005 > Re: I am having a problem in my asp in the recorsets running at iis 6.0 and sql 2000









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: I am having a problem in my asp in the recorsets running at iis 6.0 and sql 2000
Bob Barrows [MVP]

2005-02-22, 3:55 pm

Gabriel Mejía wrote:
> bob.
>
> conectacadena="Driver={SQL
>

Server};server="+session("SGP")+";database="+session("Basedatos")+";uid="+se
> ssion("clavesgp")+";pwd="+session("passsgp")


No, use SQLOLEDB.

conectacadena="Provider=SQLOLEDB;" & _
"Data Source=" & session("SGP") & ";" & _
"Initial Catalog=" & session("Basedatos") & ";" & _
"User ID=" & session("clavesgp") & ";" & _
"Password=" & session("passsgp")

>
>
> '-------------------------objeto conexion
>
>
> Set cn = CreateObject("adodb.connection")
> cn.open = conectacadena
>
>
>
> '---------------------------------------busco el codigo de la oficina
> que corresponde al nombre
> sql14="SELECT * FROM dbo.tblOficinas WHERE strNombre='" +
> nombreoficina + "'"


No, use parameters. That's the whole point of using a Command object:

sql14="SELECT * FROM dbo.tblOficinas WHERE strNombre=?"


> Set cmd=CreateObject("adodb.command")
> cmd.CommandType=1
> cmd.CommandText=sql14
> Set cmd.ActiveConnection = cn
>
>
> set Recordset14 = Server.CreateObject("ADODB.Recordset")


You're missing the "Set" keyword in the following statement. ALWAYS use
"Set" when dealing with object variables.
> Recordset14=cmd.Execute()


This statement should be:

Set Recordset14=cmd.Execute(,array(nombreoficina))

Then, don't try to read data from the recordset without checking its EOF
property:

If not Recordset14.EOF then

>
> '----------------------------------en las siguientes lineas se
> almcenan las rutas donde iria a quedar los
> ' archivos txt con los comprobantes
> de impresion y los archivos adjuntos.
> session("strRutaComprobantes")=Recordset14("strRutaComprobantes")
> session("strRutaAdjuntos")=Recordset14("strRutaAdjuntos")


Else
Response.Write "The recordset was empty"
End if
>
> 'Recordset14.close
> set Recordset14=nothing
> cn.Close
> Set cn = nothing
> %>
> <%
>


If the recordset was empty when you think it should contain data, verify
that nombreoficina contains the data you think it contains, by using
Response.Write nombreoficina

For further debugging, use SQL Profiler to trace the commands sent to your
SQL Server.

HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com