Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2003

Tip: Looking for answers? Try searching our database.

SQL VARIABLE

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RAW - 17 Nov 2003 00:40 GMT
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, "'", "''") + "'

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.