473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SQL VARIABLE

RAW
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.md b"
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>
Nov 18 '05 #1
5 1263
Is it because you are using the '+' sign for concatenating your string in
VB? Should you be using '&'?

-Darrin
"RAW" <de****@terra.com> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
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.md b"
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>

Nov 18 '05 #2
RAW
Hi I try your suggestion to change the + by the & where I concatanate

but I still have the same problem
let me explain when I pass my string with my variable example
whatever.aspx?Pagina=back_0

my page suposed to bring me the data from this record
and my code suppose to replace sql statement with my variable
and I dont know what Iam doing wrong this is not working

"RAW" <de****@terra.com> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
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.md b"
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>

Nov 18 '05 #3
It may help us to know what datatype the PAGINA column is.

It would also help if we knew what error you are getting.

If pagina is meant to be one to the string datatypes

Try this
DIM mySqlStatment as string = String.Format("Select PAGINA, NIVELES,
CONTENIDO, LINKS FROM content WHERE PAGINA = ""{0}""", Replace(setPagina,
"'", "''"))

HTH
Brian W

"RAW" <de****@terra.com> wrote in message
news:uU**************@TK2MSFTNGP09.phx.gbl...
Hi I try your suggestion to change the + by the & where I concatanate

but I still have the same problem
let me explain when I pass my string with my variable example
whatever.aspx?Pagina=back_0

my page suposed to bring me the data from this record
and my code suppose to replace sql statement with my variable
and I dont know what Iam doing wrong this is not working

"RAW" <de****@terra.com> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
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.md b"
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>


Nov 18 '05 #4
RAW
THANKS THIS RESOLVE THE PROBLEM
"RAW" <de****@terra.com> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
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.md b"
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>

Nov 18 '05 #5
Since you didn't reply to the correct post, may we ask, what solved the
problem?
"RAW" <de****@terra.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
THANKS THIS RESOLVE THE PROBLEM
"RAW" <de****@terra.com> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
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.md b"
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>


Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott | last post by:
I have an XML Document in a format like: <Variable name="Bob">ABCDEFG</Variable> <Variable name="Steve">QWERTYUI</Variable> <Variable name="John">POIUYTR</Variable> <Variable...
4
by: Frederik Sørensen | last post by:
I include a xslt stylesheet with variables for all the error messages in my system. <xsl:variable name="Banner_error_1"> errormessage 1 for banner </xsl:variable> <xsl:variable...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
10
by: Blaxer | last post by:
There is probably a really easy way to do this, so please forgive me but I would like to set the value of a variable from a variable, an example would be... function Calculate_Something(ByVal...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
3
by: rls03 | last post by:
I have the following which creates a variable containing a relative path where <xsl:value-of select="."/returns a portion of the filename: <xsl:variable...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
2
by: Florian Loitsch | last post by:
hi, What should be the output of the following code-snippet? === var x = "global"; function f() { var x = 0; eval("function x() { return false; }"); delete x; alert(x); }
37
by: minkoo.seo | last post by:
Hi. I've got a question on the differences and how to define static and class variables. AFAIK, class methods are the ones which receives the class itself as an argument, while static methods...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.