On Aug 27, 10:21 pm, "Alf P. Steinbach" <al...@start.no> wrote:
* localhar...@yahoo.ca:
I am a newbie to c++, so maybe this one's too easy, tho apparently not
for me:
1. I am using MS Visual Studio.
2. I have a std::string variable.
3. Its value might contain embedded null chars.
4. I want to insert/update it in an ADO parameter to be presented to
an SQL statement, one whose CommandText is something such as:
Select * from mytable where key = ?
So my q is, how do I convert it from its current string format into
something that ADO (i.,e. Command>-Parameter->Item[n]->Value will
accept?
I can't assign it directly, that doesn't even compile. I can't use
c_str() or any other function that employs a char * argument because
of the embedded nulls in the data, and when I try to use an
intermediate _bstr_t wrapper, the data seems to turn up garbled (can I
assume that's a single- vs double- byte problem?)
Anyway, thx if anyone can help; hope this is the correct group for
such a q.
Not really. Your question is about what characters you can use in an
SQL query. That does not include null-bytes, and it has nothing to do
with C++ or any programming language.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
"Your question is about what characters you can use in an
SQL query. That does not include null-bytes, and it has nothing to do
with C++ or any programming language. "
???
Sure it does. A char value can include any sequence of characters,
including nulls, which is why I have inherited this problem. A char
value, as typified by this case, is merely a sequence of bytes, each
of which can have any bit sequence whatsoever. This is why the
"string" class itself allows embedded nulls in the first place.
Any ideas, then, as to how to solve the orig prob, to convince a
_variant_t (which is what the ADO Parameter type is, if I'm
understanding it correctly) to accept a var, of type string, with a
value that incl's null?
Again, it's a SQL problem. You'll have to look at _variant_t and what it
expects it's input to be and how it knows where the end of the data is.
a null in the input string. Perhaps it wants it to be escaped or something.
A SQL newsgroup is probably a better place for this question.