Hello all,
I need to pass a string to a sql procedure in this fashion
<DateParam>
<BeginDate="200 7-01-25" BeginTime="08:3 0 AM" EndTime="09:45A M"/>
</DateParam>
If you notice the date and time are enclosed in double quotes. How do
I achieve this in C#
I tried using the escape sequence "\"", but the \ also gets included
and the stored procedure fails.
The stored procedure is not ours and is being called from our code to
update another db.
Any help would be appreciated
SS 8 2276
SK <sk*********@gm ail.comwrote:
Hello all,
I need to pass a string to a sql procedure in this fashion
<DateParam>
<BeginDate="200 7-01-25" BeginTime="08:3 0 AM" EndTime="09:45A M"/>
</DateParam>
If you notice the date and time are enclosed in double quotes. How do
I achieve this in C#
I tried using the escape sequence "\"", but the \ also gets included
and the stored procedure fails.
How are you specifying the text? If it's within the C# code, you need
the \ and it *won't* be in the "real" string. If it's within a file,
you *don't* need the \ as the C# compiler won't be processing it.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Another question to ask is whether or not you are using parameterized
queries to send the parameters to the stored procedure on the server, or
whether you are creating the exec statement yourself (complete with
parameters).
If you are not using the parameters collection that a command exposes
and then assigning your string to that, I would guess that most likely, you
are generating the string correctly (as a parameter) but you are not
translating it correctly when sending it to the stored procedure.
You should let the data provider model do that for you (if you are not
already).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** ************@ms news.microsoft. com...
SK <sk*********@gm ail.comwrote:
>Hello all, I need to pass a string to a sql procedure in this fashion <DateParam> <BeginDate="20 07-01-25" BeginTime="08:3 0 AM" EndTime="09:45A M"/> </DateParam>
If you notice the date and time are enclosed in double quotes. How do I achieve this in C# I tried using the escape sequence "\"", but the \ also gets included and the stored procedure fails.
How are you specifying the text? If it's within the C# code, you need
the \ and it *won't* be in the "real" string. If it's within a file,
you *don't* need the \ as the C# compiler won't be processing it.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
On May 4, 2:06 pm, Jon Skeet [C# MVP] <s...@pobox.com wrote:
SK <skrishna...@gm ail.comwrote:
Hello all,
I need to pass a string to a sql procedure in this fashion
<DateParam>
<BeginDate="200 7-01-25" BeginTime="08:3 0 AM" EndTime="09:45A M"/>
</DateParam>
If you notice the date and time are enclosed in double quotes. How do
I achieve this in C#
I tried using the escape sequence "\"", but the \ also gets included
and the stored procedure fails.
How are you specifying the text? If it's within the C# code, you need
the \ and it *won't* be in the "real" string. If it's within a file,
you *don't* need the \ as the C# compiler won't be processing it.
--
Jon Skeet - <s...@pobox.com >http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
The string is within C# code and not within a file. I tried using
"\"". The string that gets passed to sql looks like this
<DateParam>
<BeginDate=\"20 07-05-30\" BeginTime=\"8:0 0 AM\" EndTime=\"9:00 AM\"/>
</DateParam>
On May 4, 2:44 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
Another question to ask is whether or not you are using parameterized
queries to send the parameters to the stored procedure on the server, or
whether you are creating the exec statement yourself (complete with
parameters).
If you are not using the parameters collection that a command exposes
and then assigning your string to that, I would guess that most likely, you
are generating the string correctly (as a parameter) but you are not
translating it correctly when sending it to the stored procedure.
You should let the data provider model do that for you (if you are not
already).
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard .caspershouse.c om
"Jon Skeet [C# MVP]" <s...@pobox.com wrote in messagenews:MP* *************** ****@msnews.mic rosoft.com...
SK <skrishna...@gm ail.comwrote:
Hello all,
I need to pass a string to a sql procedure in this fashion
<DateParam>
<BeginDate="200 7-01-25" BeginTime="08:3 0 AM" EndTime="09:45A M"/>
</DateParam>
If you notice the date and time are enclosed in double quotes. How do
I achieve this in C#
I tried using the escape sequence "\"", but the \ also gets included
and the stored procedure fails.
How are you specifying the text? If it's within the C# code, you need
the \ and it *won't* be in the "real" string. If it's within a file,
you *don't* need the \ as the C# compiler won't be processing it.
--
Jon Skeet - <s...@pobox.com > http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too- Hide quoted text -
- Show quoted text -
I am using parameterized queries.
SK <sk*********@gm ail.comwrote:
How are you specifying the text? If it's within the C# code, you need
the \ and it *won't* be in the "real" string. If it's within a file,
you *don't* need the \ as the C# compiler won't be processing it.
The string is within C# code and not within a file. I tried using
"\"". The string that gets passed to sql looks like this
<DateParam>
<BeginDate=\"20 07-05-30\" BeginTime=\"8:0 0 AM\" EndTime=\"9:00 AM\"/>
</DateParam>
My guess is that you're viewing that in the debugger - if so, the
slashes really aren't there.
Try printing it to a message box or to the console and you'll see the
real string.
See http://pobox.com/~skeet/csharp/strings.html#debugger for more on
this.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
On May 4, 3:10 pm, Jon Skeet [C# MVP] <s...@pobox.com wrote:
SK <skrishna...@gm ail.comwrote:
How are you specifying the text? If it's within the C# code, you need
the \ and it *won't* be in the "real" string. If it's within a file,
you *don't* need the \ as the C# compiler won't be processing it.
The string is within C# code and not within a file. I tried using
"\"". The string that gets passed to sql looks like this
<DateParam>
<BeginDate=\"20 07-05-30\" BeginTime=\"8:0 0 AM\" EndTime=\"9:00 AM\"/>
</DateParam>
My guess is that you're viewing that in the debugger - if so, the
slashes really aren't there.
Try printing it to a message box or to the console and you'll see the
real string.
Seehttp://pobox.com/~skeet/csharp/strings.html#de buggerfor more on
this.
--
Jon Skeet - <s...@pobox.com >http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
You are right Jon. I am viewing that in the debugger. But will it be
without the the slashes when the procedure is being executed?
Thanks for your responses
S
SK wrote:
On May 4, 3:10 pm, Jon Skeet [C# MVP] <s...@pobox.com wrote:
>SK <skrishna...@gm ail.comwrote:
>>>How are you specifying the text? If it's within the C# code, you need the \ and it *won't* be in the "real" string. If it's within a file, you *don't* need the \ as the C# compiler won't be processing it. The string is within C# code and not within a file. I tried using "\"". The string that gets passed to sql looks like this <DateParam> <BeginDate=\" 2007-05-30\" BeginTime=\"8:0 0 AM\" EndTime=\"9:00 AM\"/> </DateParam>
My guess is that you're viewing that in the debugger - if so, the slashes really aren't there.
Try printing it to a message box or to the console and you'll see the real string.
Seehttp://pobox.com/~skeet/csharp/strings.html#de buggerfor more on this.
-- Jon Skeet - <s...@pobox.com >http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too
You are right Jon. I am viewing that in the debugger. But will it be
without the the slashes when the procedure is being executed?
Thanks for your responses
S
Yes.
--
Göran Andersson
_____ http://www.guffa.com
SK <sk*********@gm ail.comwrote:
You are right Jon. I am viewing that in the debugger. But will it be
without the the slashes when the procedure is being executed?
Thanks for your responses
As I said before, it doesn't have the slashes in at all - it's just the
debugger trying to be smart (and failing - it confuses lots of people).
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Saur |
last post by:
Hi,
I am using an export to excel functionality from my ASP
page.
I have set the content type as
Response.ContentType = "application/vnd.ms-excel"
The data i am exporting has values like 1-2, 2-5
Now when they get exported to excel, these values get
exported as 1-02-2003,2-05-2003.
|
by: Drifter |
last post by:
The quote below is part of the information i want to save to a MS Access
database - or update, as the case may be.
The original database was built a long time ago, and looking at the code for
add/update on the original site-it does not compensate for odd syntax like
the quotes. Problem i am hitting now is syntax issue in the SQL when I go to
save/update. The syntax present causes failures every time.
User said she had no problems...
|
by: EdUarDo |
last post by:
I think it's a common problem, but I haven't found answers for it.
I have a sentence (mixture of HTML, Javascript and JSTL) like this:
<a href='javascript:selectItem('${item.code}', '${item.alias}');
${item.alias}
</a>
${item.alias} is a JSTL way to get a String from a parameter
that may contains single or double quotes.
|
by: deko |
last post by:
I'm trying to log error messages and sometimes (no telling when or where)
the message contains a string with double quotes. Is there a way get the
query to insert the string with the double quotes? Do I need to use code to
scrub each string and remove or escape the double quotes before using it in
a query?
The error I get is this:
Error Number 3075: Syntax error (missing operator) in query expression
'"credit card billed by...
|
by: (PeteCresswell) |
last post by:
Is his just a flat-out "No-No" or is there some workaround when it comes time
for SQL searches and DAO.FindFirsts against fields containing same?
I can see maybe wrapping the value searched for in single quotes to deal with
embedded double quotes, but if there are both embedded single AND double quotes,
I can't see any way to deal with it.
So, am I doing the right thing to remove all embedded double quotes from my data
and write...
| |
by: gar |
last post by:
Hi,
I need to replace all the double quotes (") in a textbox with single quotes ('). I used this code
text= Replace(text, """", "'"
This works fine (for normal double quotes).The problem comes in when you copy a double quote from MS Word and paste it in the text box. What happens is the double quote becomes slanted (“) so my code above can't filter it. I tried to do this
text= Replace(text, "““","'")
|
by: graphicsxp |
last post by:
Hi,
I have a SQL stored procedure which looks like that:
SELECT @QuerySQL = 'SELECT as LookupField,
G.GroupDesc + ' + '" : "' + ' + as DescField
FROM '
+ 'JOIN ItemGrouping IG on IG.CatID =' + cast(@CatID as varchar(50)) +
'and ItemID =
JOIN G on G.GroupID = IG.GroupID
ORDER BY DescField'
|
by: fniles |
last post by:
I am looping thru DataReader and constructing a sql query to insert to
another database.
When the data type of the field is string I insert the field value using a
single quote.
When the value of the field has a single quote in it like "O'Toole", how can
I construct the string ?
Do While drSQL.Read
sSQL = "insert into " & sTableName & " values ("
sSQL2 = ""
|
by: Queez |
last post by:
I have an issue with an ASP repeater which is seriously frustrating me.
In simple terms, I have an ASP repeater which is meant to display a list of items for a wedding list, including the name of the item, how many are available and a button to take the user to a "purchase" form where they select how many they wish to purchase. Once they're done, the page is reloaded and the new "number available" is displayed. Sounds simple, huh?
Well...
|
by: Julien |
last post by:
Hi,
I'm fairly new in Python and I haven't used the regular expressions
enough to be able to achieve what I want.
I'd like to select terms in a string, so I can then do a search in my
database.
query = ' " some words" with and "without quotes " '
p = re.compile(magic_regular_expression) $ <--- the magic happens
m = p.match(query)
|
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: 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: 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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |