Can someone tell me how I convert this simple SQL statement so I can use it
in ASP.NET???
I have an issue with the quotation marks and wondered if there is a simple
rule for converting the sql statement so if can be used in ASP.NEt!
Thanks
... SQL String
SELECT (CASE WHEN ImgLeft IS NULL THEN '' ELSE '<img src="' + ImgLeft + '"
/> ' END) + [Text] +
(CASE WHEN ImgRight IS NULL THEN '' ELSE ' <img src="' + ImgRight + '" />'
END) AS [Text],
ISNULL(ToolTip, '') AS ToolTip,
ISNULL(Url, '') AS Url,
[ID],
(SELECT COUNT(*) FROM APP_Menu B WHERE B.ParentID = A.ID) AS
SubMenuItemsCou nt
FROM APP_Menu A
WHERE Display = 1
AND ParentId = @ParentID
ORDER BY ParentID, DisplayOrder 5 1739
//Replace embedded ' with '' (two single quotes)
string sql = sql.Replace(@"' ", @"''");
---
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
*************** ************
Think Outside the Box!
*************** ************
"Tim::.." wrote: Can someone tell me how I convert this simple SQL statement so I can use it in ASP.NET???
I have an issue with the quotation marks and wondered if there is a simple rule for converting the sql statement so if can be used in ASP.NEt!
Thanks
.. SQL String
SELECT (CASE WHEN ImgLeft IS NULL THEN '' ELSE '<img src="' + ImgLeft + '" /> ' END) + [Text] + (CASE WHEN ImgRight IS NULL THEN '' ELSE ' <img src="' + ImgRight + '" />' END) AS [Text], ISNULL(ToolTip, '') AS ToolTip, ISNULL(Url, '') AS Url, [ID], (SELECT COUNT(*) FROM APP_Menu B WHERE B.ParentID = A.ID) AS SubMenuItemsCou nt FROM APP_Menu A WHERE Display = 1 AND ParentId = @ParentID ORDER BY ParentID, DisplayOrder
That wasn't exactly my problem!
The problem is I can't get the sql into a string!
This is the closest I got to it!
"SELECT (CASE WHEN ImgLeft IS NULL THEN '' ELSE '<img src='" & Chr(34) &
"ImgLeft" & Chr(34) & "' /> ' END) + [Text] + (CASE WHEN ImgRight IS NULL
THEN '' ELSE ' <img src='" & Chr(34) & "ImgRight" & Chr(34) & "' />' END) AS
Text, ISNULL(ToolTip, '') AS ToolTip, ISNULL(Url, '') AS Url, [ID], (SELECT
COUNT(*) FROM APP_Menu B WHERE B.ParentID = A.ID) AS SubMenuItemsCou nt() FROM
APP_Menu A WHERE(Display = 1) AND ParentId = @ParentID ORDER BY ParentID,
DisplayOrder"
Thanks
"Cowboy (Gregory A. Beamer) - MVP" wrote: //Replace embedded ' with '' (two single quotes) string sql = sql.Replace(@"' ", @"''");
---
Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA
*************** ************ Think Outside the Box! *************** ************
"Tim::.." wrote:
Can someone tell me how I convert this simple SQL statement so I can use it in ASP.NET???
I have an issue with the quotation marks and wondered if there is a simple rule for converting the sql statement so if can be used in ASP.NEt!
Thanks
.. SQL String
SELECT (CASE WHEN ImgLeft IS NULL THEN '' ELSE '<img src="' + ImgLeft + '" /> ' END) + [Text] + (CASE WHEN ImgRight IS NULL THEN '' ELSE ' <img src="' + ImgRight + '" />' END) AS [Text], ISNULL(ToolTip, '') AS ToolTip, ISNULL(Url, '') AS Url, [ID], (SELECT COUNT(*) FROM APP_Menu B WHERE B.ParentID = A.ID) AS SubMenuItemsCou nt FROM APP_Menu A WHERE Display = 1 AND ParentId = @ParentID ORDER BY ParentID, DisplayOrder
> The problem is I can't get the sql into a string!
Looks like a string to me. A String is an array of characters. A String
literal is a sequence of characters enclosed with double quotes. When you
replace the single quotes in it with doubled single quotes, you make it
readable to the database. You should also (as it seems you have) replace
double quotes with CHR(34). When you enclose the whole mess inside a pair of
double quotes, you have a string.
As a side note: You'd be better off leaving all that logic and
string-building out of your SQL Statement. You can replace nulls in your
application with whatever you need. All that logic in a SQL Statement is
going to slow things down.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
"Tim::.." <myatix_at_hotm ail.com> wrote in message
news:7A******** *************** ***********@mic rosoft.com... That wasn't exactly my problem!
The problem is I can't get the sql into a string!
This is the closest I got to it!
"SELECT (CASE WHEN ImgLeft IS NULL THEN '' ELSE '<img src='" & Chr(34) & "ImgLeft" & Chr(34) & "' /> ' END) + [Text] + (CASE WHEN ImgRight IS NULL THEN '' ELSE ' <img src='" & Chr(34) & "ImgRight" & Chr(34) & "' />' END) AS Text, ISNULL(ToolTip, '') AS ToolTip, ISNULL(Url, '') AS Url, [ID], (SELECT COUNT(*) FROM APP_Menu B WHERE B.ParentID = A.ID) AS SubMenuItemsCou nt() FROM APP_Menu A WHERE(Display = 1) AND ParentId = @ParentID ORDER BY ParentID, DisplayOrder"
Thanks
"Cowboy (Gregory A. Beamer) - MVP" wrote:
//Replace embedded ' with '' (two single quotes) string sql = sql.Replace(@"' ", @"''");
---
Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA
*************** ************ Think Outside the Box! *************** ************
"Tim::.." wrote:
> Can someone tell me how I convert this simple SQL statement so I can > use it > in ASP.NET??? > > I have an issue with the quotation marks and wondered if there is a > simple > rule for converting the sql statement so if can be used in ASP.NEt! > > Thanks > > .. SQL String > > SELECT (CASE WHEN ImgLeft IS NULL THEN '' ELSE '<img src="' + ImgLeft + > '" > /> ' END) + [Text] + > (CASE WHEN ImgRight IS NULL THEN '' ELSE ' <img src="' + ImgRight + '" > />' > END) AS [Text], > ISNULL(ToolTip, '') AS ToolTip, > ISNULL(Url, '') AS Url, > [ID], > (SELECT COUNT(*) FROM APP_Menu B WHERE B.ParentID = A.ID) AS > SubMenuItemsCou nt > FROM APP_Menu A > WHERE Display = 1 > AND ParentId = @ParentID > ORDER BY ParentID, DisplayOrder
try using a stringbuilder class.
"Tim::.." <myatix_at_hotm ail.com> wrote in message
news:A3******** *************** ***********@mic rosoft.com... Can someone tell me how I convert this simple SQL statement so I can use it in ASP.NET???
I have an issue with the quotation marks and wondered if there is a simple rule for converting the sql statement so if can be used in ASP.NEt!
Thanks
.. SQL String
SELECT (CASE WHEN ImgLeft IS NULL THEN '' ELSE '<img src="' + ImgLeft + '" /> ' END) + [Text] + (CASE WHEN ImgRight IS NULL THEN '' ELSE ' <img src="' + ImgRight + '" />' END) AS [Text], ISNULL(ToolTip, '') AS ToolTip, ISNULL(Url, '') AS Url, [ID], (SELECT COUNT(*) FROM APP_Menu B WHERE B.ParentID = A.ID) AS SubMenuItemsCou nt FROM APP_Menu A WHERE Display = 1 AND ParentId = @ParentID ORDER BY ParentID, DisplayOrder
Try this:
string sql = "SELECT (CASE WHEN ImgLeft IS NULL THEN '''' ELSE ''<img
src=\"'' + ImgLeft + ''\" /> '' END) + [Text] + (CASE WHEN ImgRight IS NULL
THEN '''' ELSE '' <img src=\"'' + ImgRight + ''\" />'' END) AS
[Text], ISNULL(ToolTip, '''') AS ToolTip, ISNULL(Url, '''') AS
Url, [ID], (SELECT COUNT(*) FROM APP_Menu B WHERE B.ParentID = A.ID) AS
SubMenuItemsCou nt FROM APP_Menu A WHERE Display = 1 AND ParentId = @ParentID
ORDER BY ParentID, DisplayOrder)";
or this
System.Text.Str ingBuilder sql = new System.Text.Str ingBuilder();
sql.Append("SEL ECT (CASE WHEN ImgLeft IS NULL THEN '''' ELSE ''<img src=\"''
+ ImgLeft + ''\" /> '' END) + [Text] + (CASE WHEN ImgRight IS NULL THEN ''''
ELSE '' <img src=\"'' + ImgRight + ''\" />'' END) AS [Text], ISNULL(ToolTip,
'''') AS ToolTip, ISNULL(Url, '''') AS Url, [ID], (SELECT COUNT(*) FROM
APP_Menu B WHERE B.ParentID = A.ID) AS SubMenuItemsCou nt FROM APP_Menu A
WHERE Display = 1 AND ParentId = @ParentID ORDER BY ParentID, DisplayOrder)") ;
Basically what I did was use the \ (string literal escape) and used '' in
place of any ' as Greg suggested. I do agree with Kevin's statement
regarding the slowness of the sql statement, but that's beyond the scope of
your question.
HTH
Jeff Davis
"Tim::.." wrote: Can someone tell me how I convert this simple SQL statement so I can use it in ASP.NET???
I have an issue with the quotation marks and wondered if there is a simple rule for converting the sql statement so if can be used in ASP.NEt!
Thanks
.. SQL String
SELECT (CASE WHEN ImgLeft IS NULL THEN '' ELSE '<img src="' + ImgLeft + '" /> ' END) + [Text] + (CASE WHEN ImgRight IS NULL THEN '' ELSE ' <img src="' + ImgRight + '" />' END) AS [Text], ISNULL(ToolTip, '') AS ToolTip, ISNULL(Url, '') AS Url, [ID], (SELECT COUNT(*) FROM APP_Menu B WHERE B.ParentID = A.ID) AS SubMenuItemsCou nt FROM APP_Menu A WHERE Display = 1 AND ParentId = @ParentID ORDER BY ParentID, DisplayOrder This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: one man army |
last post by:
Hi All-
I am new to PHP. I found FAQTS and the php manual. I am trying this
sequence, but getting 'no zip string found:'... PHP Version 4.4.0
$doc = new DomDocument;
$res = $doc->loadHTMLFile("./aBasicSearchResult.html");
if ( $res == true )
{
$zip = $doc->getElementById('zipRaw_id')->value;
if ( 0 != $zip ) {
|
by: dba_222 |
last post by:
Dear Experts,
Ok, I hate to ask such a seemingly dumb question, but I've
already spent far too much time on this. More that I
would care to admit.
In Sql server, how do I simply change a character into a number??????
In Oracle, it is:
|
by: rdrink |
last post by:
I am just getting into pysqlite (with a fair amount of Python and MySQL
experience behind me) and have coded a simple test case to try to get
the hang of things...
yet have run into a 'stock simple' problem...
I can create a database 'test.db', add a table 'foo' (which BTW I
repeatedly DROP on each run) with one INTGER column 'id', and can
insert data into with:
cur.execute("INSERT INTO foo (id) VALUES (200)")
con.commit()
|
by: Phillip Vong |
last post by:
Using VS2005 w/ simple aspx in VB.net
I have a simple databound textbox "LastMtgText" in a formview in the Insert
template.
All I want to do is make the default date of today when someone goes to
Insert template so they do not have to put in todays date. Here is my code,
what am I doing wrong? I know how to do this when not using Formview.
'-----This puts in the current date
|
by: Emin |
last post by:
Dear Experts,
I have a fairly simple query in which adding a where clause slows
things down by at least a factor of 100. The following is the slow
version of the query
-------------------------
SELECT * FROM
( Select x.event_date From x FULL OUTER JOIN y
ON x.event_date = y.event_date
| |
by: Chelong |
last post by:
hey,the follow is the text file content
========================================apple====pear==
one Lily 7 0 0 7 7
two Lily 20 20 6.6666 20 8
one Lily 0 10 2.85 4 0
two Lily 22 22 7.33326 2 5
two jenny 6 0 0 6 6
two jenny 12 0 0 12 12
three jenny 36 36 10.26 36 36
|
by: Dustin MacDonald |
last post by:
Hi everyone.
This is my first time posting to this newsgroup, and although I
maintain my netiquette I might've missed something specific to the
newsgroup, so hopefully you can avoid flaming me if I have :) I
apologize for the length of this post but I figure the more
information the better.
My problem is that I'm getting a syntax error in some Python code that
looks quite simple. The original code was in Object Pascal as I'm a
|
by: Nightfall |
last post by:
Dear friends,
consider the following scenario, in Visual Studio 2005 and C#
- I create a ASP.NET web service ("server") with a class MyClass and a
WebMethod SomeMethod()
- I create a client application, using "Add web reference..." and
specifying some web reference name "MyName"
Normally I would do:
|
by: galiorenye |
last post by:
Hi,
Given this code:
A** ppA = new A*;
A *pA = NULL;
for(int i = 0; i < 10; ++i)
{
pA = ppA;
//do something with pA
|
by: Phillip Taylor |
last post by:
Hi guys, I'm looking to develop a simple web service in VB.NET but I'm
having some trivial issues. In Visual Studio I create a web services
project and change the asmx.vb file to this:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
<System.Web.Services.WebService(Namespace:="http://
wwwpreview.#deleted#.co.uk/~ptaylor/Customer.wsdl")_
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |