473,394 Members | 1,663 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,394 software developers and data experts.

Syntax in asp page

Can anybody tell me about this:

conn.ConnectionString = "SELECT [Customernr], [Customername],
[OrderID], [Orderdate], [Itemname], [Ordersum], [Orderdiscount],
[Orderprice], [Orderamount] " + "\n" +
"WHERE Customernr = "' + <%txtCustnr.Text %+ '" FROM
[CustomerOrderHistory] ORDER BY [Orderdate]";

So what I try to obtain is getting a value from a textbox: txtCustnr.

The code is C# in an ASP 2.0 application

But this syntax drives me mad.

Any tip?

Jan 15 '07 #1
5 1168

"Krij" <gs***@start.nowrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
Can anybody tell me about this:

conn.ConnectionString = "SELECT [Customernr], [Customername],
[OrderID], [Orderdate], [Itemname], [Ordersum], [Orderdiscount],
[Orderprice], [Orderamount] " + "\n" +
"WHERE Customernr = "' + <%txtCustnr.Text %+ '" FROM
[CustomerOrderHistory] ORDER BY [Orderdate]";

So what I try to obtain is getting a value from a textbox: txtCustnr.

The code is C# in an ASP 2.0 application

But this syntax drives me mad.

Any tip?
You should try a dotnet group rather than this one, which deals with classic
asp. The busiest ones are microsoft.public.dotnet.framework.aspnet, or the
forums at www.asp.net. I suggest that future asp.net related questions are
posted there, because you will likely get a much quicker response.

However, the reason that the syntax is driving you mad is because you are
trying to assign a (badly formed) SQL statement to the ConnectionString
property. In fact, the SQL statement should be the CommandText.

There are a number of ways of approaching what you want to achieve. But, I
suggest that if you haven't already done so, you download a copy of
Microsoft Visual Web Developer, which is free, and use the wizards to
configure a DataSource, which will prompt you for the source of any
parameters that you want to feed into the query. In your case, the source
will be a control, txtCustomer. It will also help you to construct a SQL
statement properly.

--
Mike Brind
Jan 15 '07 #2
"WHERE Customernr = "' + <%txtCustnr.Text %+ '" FROM

Try re-coding this line to be:

"WHERE Customernr = '" + <% =txtCustnr.Text %+ "' FROM

Brian
Jan 15 '07 #3
Brian Staff wrote on 15 jan 2007 in
microsoft.public.inetserver.asp.general:
>"WHERE Customernr = "' + <%txtCustnr.Text %+ '" FROM

Try re-coding this line to be:

"WHERE Customernr = '" + <% =txtCustnr.Text %+ "' FROM

Brian
A number being a number in the database, not a string,
and the SQL string being in the asp code part already,
and expecting ASP-VBS,
try:

sql = " ... WHERE Customernr = " & +txtCustnr.Text & " FROM ..."

or asp-Jscript:

sql = " ... WHERE Customernr = " + +txtCustnr.Text + " FROM ...";
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 15 '07 #4
Krij wrote:
Can anybody tell me about this:

conn.ConnectionString = "SELECT [Customernr], [Customername],
[OrderID], [Orderdate], [Itemname], [Ordersum], [Orderdiscount],
[Orderprice], [Orderamount] " + "\n" +
"WHERE Customernr = "' + <%txtCustnr.Text %+ '" FROM
[CustomerOrderHistory] ORDER BY [Orderdate]";
Yes. That is not a connection string.
http://msdn.microsoft.com/library/en...tionstring.asp

Perhaps you want conn.Execute("SELECT ...")
http://msdn.microsoft.com/library/en...cnnexecute.asp

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Jan 15 '07 #5
Evertjan,

Yes, after re-reading my post, I declare it's completely wrong regarding server
and client code....so please dis-regard it.

I was focused on getting the quotes in the correct order and consequently did
not pay attention to the other details.

Sorry about that....Monday morning<g>

Brian

Jan 15 '07 #6

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

Similar topics

4
by: Xah Lee | last post by:
while programing in Python, one can lookup syntax or info for keywords or modules within Python. In the command line, type python to get into the python interactive program. then type...
29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
5
by: NanQuan | last post by:
I'm hoping someone can help me solve this error since I am at a total loss here. Usually I don't bother posting on any forums or groups on the internet and prefer to solve stuff myself but this is...
4
by: Toonman | last post by:
I'm trying to use a couple of variables in a stored procedure. Things work fine when I hard code the data into the variables and also work fine when I use the variable in the WHERE clause and hard...
3
by: muchan | last post by:
A simple question. (Sorry, if it's already in FAQ) What is the syntax definition language used in the XML 1.0 page of the W3C <http://www.w3.org/TR/REC-xml/>? I searched some syntax definition...
0
by: Mark Phanides | last post by:
My ASP.NET application intermittantly (but always at same point) redirects to the 'Invalid Syntax Error' web page for some unknown reason. I've created a ASP.NET application written in VB.NET with...
1
by: MadHatter51 | last post by:
I have an application where a selection is made from a list on a web page. I have written a class to handle some database processing and then wish to pass a bunch of data objects to another web...
7
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM",...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
2
by: Chris Walls | last post by:
We have created two (2) global resource files in App_GlobalResouces: Global.resx Global.es-MX.resx In an ASP.NET page, we use two different syntaxes to set text on the page, depending upon the...
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
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...

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.