473,545 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=Micro soft.Jet.OLEDB. 4.0; Data
Source="& _
'Server.MapPath ("../NEWMGS/dbcontainer/content.mdb")

'Absolute connection
Dim strConnection as String = "Provider=Micro soft.Jet.OLEDB. 4.0; Data
Source=D:\works \WEBS\NEWMGS\db container\conte nt.mdb"
DIM setNiveles AS INTEGER
DIM setContenido AS STRING
DIM setPagina AS STRING

'requesting my variable forma a querystring

setPagina = Request.QuerySt ring("PAGINA")
setNiveles = Request.QuerySt ring("NIVELES")
setContenido = Request.QuerySt ring("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(setPagi na, "'", "''") + ""
*************** *****

DIM objConnection AS NEW OledbConnection (strConnection)
DIM objCommand as NEW oledbCommand(my SqlStatment, objConnection)
DIM objDataReader as oledbDataReader

try
objConnection.o pen()
objDataReader = objCommand.Exec uteReader()

DO WHILE objDataReader.R ead()= true

Response.write( objDataReader(s etPagina))
Response.write( "=")
Response.write( objDataReader(" NIVELES"))
'Response.write (setNiveles)
'Response.write ("&")
'Response.write ("Contenido" )
'Response.write ("=")
'Response.write (setContenido)
'Response.write ("&")

loop
objDataReader.c lose()
objConnection.c lose()

Catch e as EXCEPTION
end try
end Sub

</Script>
Nov 18 '05 #1
5 1267
Is it because you are using the '+' sign for concatenating your string in
VB? Should you be using '&'?

-Darrin
"RAW" <de****@terra.c om> wrote in message
news:Oz******** ******@TK2MSFTN GP09.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=Micro soft.Jet.OLEDB. 4.0; Data
Source="& _
'Server.MapPath ("../NEWMGS/dbcontainer/content.mdb")

'Absolute connection
Dim strConnection as String = "Provider=Micro soft.Jet.OLEDB. 4.0; Data
Source=D:\works \WEBS\NEWMGS\db container\conte nt.mdb"
DIM setNiveles AS INTEGER
DIM setContenido AS STRING
DIM setPagina AS STRING

'requesting my variable forma a querystring

setPagina = Request.QuerySt ring("PAGINA")
setNiveles = Request.QuerySt ring("NIVELES")
setContenido = Request.QuerySt ring("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(setPagi na, "'", "''") + ""
*************** *****

DIM objConnection AS NEW OledbConnection (strConnection)
DIM objCommand as NEW oledbCommand(my SqlStatment, objConnection)
DIM objDataReader as oledbDataReader

try
objConnection.o pen()
objDataReader = objCommand.Exec uteReader()

DO WHILE objDataReader.R ead()= true

Response.write( objDataReader(s etPagina))
Response.write( "=")
Response.write( objDataReader(" NIVELES"))
'Response.write (setNiveles)
'Response.write ("&")
'Response.write ("Contenido" )
'Response.write ("=")
'Response.write (setContenido)
'Response.write ("&")

loop
objDataReader.c lose()
objConnection.c lose()

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?P agina=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.c om> wrote in message
news:Oz******** ******@TK2MSFTN GP09.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=Micro soft.Jet.OLEDB. 4.0; Data
Source="& _
'Server.MapPath ("../NEWMGS/dbcontainer/content.mdb")

'Absolute connection
Dim strConnection as String = "Provider=Micro soft.Jet.OLEDB. 4.0; Data
Source=D:\works \WEBS\NEWMGS\db container\conte nt.mdb"
DIM setNiveles AS INTEGER
DIM setContenido AS STRING
DIM setPagina AS STRING

'requesting my variable forma a querystring

setPagina = Request.QuerySt ring("PAGINA")
setNiveles = Request.QuerySt ring("NIVELES")
setContenido = Request.QuerySt ring("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(setPagi na, "'", "''") + ""
*************** *****

DIM objConnection AS NEW OledbConnection (strConnection)
DIM objCommand as NEW oledbCommand(my SqlStatment, objConnection)
DIM objDataReader as oledbDataReader

try
objConnection.o pen()
objDataReader = objCommand.Exec uteReader()

DO WHILE objDataReader.R ead()= true

Response.write( objDataReader(s etPagina))
Response.write( "=")
Response.write( objDataReader(" NIVELES"))
'Response.write (setNiveles)
'Response.write ("&")
'Response.write ("Contenido" )
'Response.write ("=")
'Response.write (setContenido)
'Response.write ("&")

loop
objDataReader.c lose()
objConnection.c lose()

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(setPagi na,
"'", "''"))

HTH
Brian W

"RAW" <de****@terra.c om> wrote in message
news:uU******** ******@TK2MSFTN GP09.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?P agina=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.c om> wrote in message
news:Oz******** ******@TK2MSFTN GP09.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=Micro soft.Jet.OLEDB. 4.0; Data
Source="& _
'Server.MapPath ("../NEWMGS/dbcontainer/content.mdb")

'Absolute connection
Dim strConnection as String = "Provider=Micro soft.Jet.OLEDB. 4.0; Data
Source=D:\works \WEBS\NEWMGS\db container\conte nt.mdb"
DIM setNiveles AS INTEGER
DIM setContenido AS STRING
DIM setPagina AS STRING

'requesting my variable forma a querystring

setPagina = Request.QuerySt ring("PAGINA")
setNiveles = Request.QuerySt ring("NIVELES")
setContenido = Request.QuerySt ring("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(setPagi na, "'", "''") + ""
*************** *****

DIM objConnection AS NEW OledbConnection (strConnection)
DIM objCommand as NEW oledbCommand(my SqlStatment, objConnection)
DIM objDataReader as oledbDataReader

try
objConnection.o pen()
objDataReader = objCommand.Exec uteReader()

DO WHILE objDataReader.R ead()= true

Response.write( objDataReader(s etPagina))
Response.write( "=")
Response.write( objDataReader(" NIVELES"))
'Response.write (setNiveles)
'Response.write ("&")
'Response.write ("Contenido" )
'Response.write ("=")
'Response.write (setContenido)
'Response.write ("&")

loop
objDataReader.c lose()
objConnection.c lose()

Catch e as EXCEPTION
end try
end Sub

</Script>


Nov 18 '05 #4
RAW
THANKS THIS RESOLVE THE PROBLEM
"RAW" <de****@terra.c om> wrote in message
news:Oz******** ******@TK2MSFTN GP09.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=Micro soft.Jet.OLEDB. 4.0; Data
Source="& _
'Server.MapPath ("../NEWMGS/dbcontainer/content.mdb")

'Absolute connection
Dim strConnection as String = "Provider=Micro soft.Jet.OLEDB. 4.0; Data
Source=D:\works \WEBS\NEWMGS\db container\conte nt.mdb"
DIM setNiveles AS INTEGER
DIM setContenido AS STRING
DIM setPagina AS STRING

'requesting my variable forma a querystring

setPagina = Request.QuerySt ring("PAGINA")
setNiveles = Request.QuerySt ring("NIVELES")
setContenido = Request.QuerySt ring("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(setPagi na, "'", "''") + ""
*************** *****

DIM objConnection AS NEW OledbConnection (strConnection)
DIM objCommand as NEW oledbCommand(my SqlStatment, objConnection)
DIM objDataReader as oledbDataReader

try
objConnection.o pen()
objDataReader = objCommand.Exec uteReader()

DO WHILE objDataReader.R ead()= true

Response.write( objDataReader(s etPagina))
Response.write( "=")
Response.write( objDataReader(" NIVELES"))
'Response.write (setNiveles)
'Response.write ("&")
'Response.write ("Contenido" )
'Response.write ("=")
'Response.write (setContenido)
'Response.write ("&")

loop
objDataReader.c lose()
objConnection.c lose()

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.c om> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
THANKS THIS RESOLVE THE PROBLEM
"RAW" <de****@terra.c om> wrote in message
news:Oz******** ******@TK2MSFTN GP09.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=Micro soft.Jet.OLEDB. 4.0; Data
Source="& _
'Server.MapPath ("../NEWMGS/dbcontainer/content.mdb")

'Absolute connection
Dim strConnection as String = "Provider=Micro soft.Jet.OLEDB. 4.0; Data
Source=D:\works \WEBS\NEWMGS\db container\conte nt.mdb"
DIM setNiveles AS INTEGER
DIM setContenido AS STRING
DIM setPagina AS STRING

'requesting my variable forma a querystring

setPagina = Request.QuerySt ring("PAGINA")
setNiveles = Request.QuerySt ring("NIVELES")
setContenido = Request.QuerySt ring("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(setPagi na, "'", "''") + ""
*************** *****

DIM objConnection AS NEW OledbConnection (strConnection)
DIM objCommand as NEW oledbCommand(my SqlStatment, objConnection)
DIM objDataReader as oledbDataReader

try
objConnection.o pen()
objDataReader = objCommand.Exec uteReader()

DO WHILE objDataReader.R ead()= true

Response.write( objDataReader(s etPagina))
Response.write( "=")
Response.write( objDataReader(" NIVELES"))
'Response.write (setNiveles)
'Response.write ("&")
'Response.write ("Contenido" )
'Response.write ("=")
'Response.write (setContenido)
'Response.write ("&")

loop
objDataReader.c lose()
objConnection.c lose()

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
4538
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 name="Tim">ZXCVBNM</Variable> <Function id="1"> <Parameter type="String">Bob</Parameter> <Parameter type="String">Steve</Parameter>
4
3233
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 name="Banner_error_2"> errormessage 2 for banner </xsl:variable>
134
7781
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 means that if I misspell a variable name, my program will mysteriously fail to work with no error message. If you don't declare variables, you...
10
2234
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 multiplyer as integer, ByVal variable as ___?) variable = 5 * multiplyer end function What I would like this function to do is take the name of the...
23
19141
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
3945
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 name="fileName">../../data/models/<xsl:value-of select="."/>.xml</xsl:variable> I want to use this variable as an argument of the document function: <xsl:apply-templates...
1
25629
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 bad breath)? Scope describes the context in which a variable can be used. For example, if a variable's scope is a certain function, then that...
2
3665
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
5436
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 are the one which runs statically with the defining class. Hence, my understanding is that static variables must be bound to the class defining the...
112
5370
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 that may print some messages. foo(...) { if (!silent)
0
7410
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7923
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4960
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3466
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.