Hi I have a little problem here with my code Iam asp user and Im trying
to
> use vb.net on this proyect
>
> Im trying to pass varible to the sql string this is my code
>
> <Script language="vb" runat="server">
> Sub Page_Load()
> 'relative connection
> 'Dim strConnection as String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
> Source="& _
> 'Server.MapPath("../NEWMGS/dbcontainer/content.mdb")
>
> 'Absolute connection
> Dim strConnection as String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
> Source=D:\works\WEBS\NEWMGS\dbcontainer\content.mdb"
> DIM setNiveles AS INTEGER
> DIM setContenido AS STRING
> DIM setPagina AS STRING
>
> 'requesting my variable forma a querystring
>
> setPagina = Request.QueryString("PAGINA")
> setNiveles = Request.QueryString("NIVELES")
> setContenido = Request.QueryString("CONTENIDO")
> Response.write(setPagina)
>
> ********************
> HERE RIGHT HERE ITS WHERE I'AM TRYING TO REPLACE THE VARIABLE
> setPagina ---------------------------------------------~v
> DIM mySqlStatment as string = "Select PAGINA, NIVELES, CONTENIDO, LINKS
FROM
> content WHERE PAGINA = " + Replace(setPagina, "'", "''") + ""
> ********************
>
> DIM objConnection AS NEW OledbConnection(strConnection)
> DIM objCommand as NEW oledbCommand(mySqlStatment, objConnection)
> DIM objDataReader as oledbDataReader
>
> try
> objConnection.open()
> objDataReader = objCommand.ExecuteReader()
>
> DO WHILE objDataReader.Read()= true
>
> Response.write(objDataReader(setPagina))
> Response.write("=")
> Response.write(objDataReader("NIVELES"))
> 'Response.write(setNiveles)
> 'Response.write("&")
> 'Response.write("Contenido")
> 'Response.write("=")
> 'Response.write(setContenido)
> 'Response.write("&")
>
> loop
> objDataReader.close()
> objConnection.close()
>
> Catch e as EXCEPTION
> end try
> end Sub
>
> </Script
Manny - 18 Nov 2003 18:31 GMT
Do you need single quotes around the variable
Change from
WHERE PAGINA = " + Replace(setPagina, "'", "''") + "
to
WHERE PAGINA = '" + Replace(setPagina, "'", "''") + "'