By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,170 Members | 1,053 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,170 IT Pros & Developers. It's quick & easy.

string conversion problems

P: n/a
i have the following line in my console app:

_bstr_t strCnn("my database connection string");

with the database connection string hard coded as above, it works, i connect
to my db.

when i read the db connection string into a string variable from the console
and try to use it or something i converted it into as the argument to strCnn
I can't connect. Any help would be appreciated.

ps

I know _bstr_t is not part of standard C++, it's a C++ class from microsoft.

there's info on _bstr_t all over the web but i still can't get my code to
work so i'm posting here.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 22 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
"alex" <al*************@verizon.net> wrote in
news:40**********@127.0.0.1:
I know _bstr_t is not part of standard C++, it's a C++ class from
microsoft.

there's info on _bstr_t all over the web but i still can't get my code
to work so i'm posting here.


A better place to ask about a Microsoft library class would be a Microsoft
newsgroup. Try one of these:

microsoft.public.vc.language
microsoft.public.vc.stl
microsoft.public.vc.atl

If your news server doesn't carry these groups, you can get them on
Microsoft's server at msnews.microsoft.com. There are hundreds of
libraries, dozens of operating systems and dozens of compilers, and if
people were to post about all these in here, it would get very noisy.

Gregg
Jul 22 '05 #2

P: n/a
"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
i have the following line in my console app:

_bstr_t strCnn("my database connection string");

with the database connection string hard coded as above, it works, i connect to my db.

when i read the db connection string into a string variable from the console and try to use it or something i converted it into as the argument to strCnn I can't connect. Any help would be appreciated.

ps

I know _bstr_t is not part of standard C++, it's a C++ class from microsoft.
there's info on _bstr_t all over the web but i still can't get my code to work so i'm posting here.

<snip>

<OT>
Just out of morbid curiosity, what exactly happened when you
tried
string dasfk = "my database connection string";
const _bstr_t strCnn(dasfk.c_str());
</OT>
Jul 22 '05 #3

P: n/a
Gregg wrote:
A better place to ask about a Microsoft library class would be a Microsoft
newsgroup. Try one of these:

microsoft.public.vc.language
microsoft.public.vc.stl
microsoft.public.vc.atl

If your news server doesn't carry these groups, you can get them on
Microsoft's server at msnews.microsoft.com. There are hundreds of
libraries, dozens of operating systems and dozens of compilers, and if
people were to post about all these in here, it would get very noisy.


And our replies would get much less accurate.

Sure I know how Gtk+'s gchar works!!

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces
Jul 22 '05 #4

P: n/a

"John Ericson" <je************@pacbell.net> wrote in message
news:4S*******************@newssvr29.news.prodigy. com...
"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
i have the following line in my console app:

_bstr_t strCnn("my database connection string");

with the database connection string hard coded as above, it works, i connect
to my db.

when i read the db connection string into a string

variable from the console
and try to use it or something i converted it into as the

argument to strCnn
I can't connect. Any help would be appreciated.

ps

I know _bstr_t is not part of standard C++, it's a C++

class from microsoft.

there's info on _bstr_t all over the web but i still can't

get my code to
work so i'm posting here.

<snip>

<OT>
Just out of morbid curiosity, what exactly happened when you
tried
string dasfk = "my database connection string";
const _bstr_t strCnn(dasfk.c_str());
</OT>


this works, i love you man


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 22 '05 #5

P: n/a
bad news

string dasfk = "my database connection string";
const _bstr_t strCnn(dasfk.c_str());

the above works but when i use the string variable that took the console
input or assign that string variable to dasfk, it doesn't work. The error
message in this and most other cases is SQL Server does not exist or access
denied.

i know the variable has the connection string in it because i display it to
output after it's read in from the console.

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...

"John Ericson" <je************@pacbell.net> wrote in message
news:4S*******************@newssvr29.news.prodigy. com...
"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
i have the following line in my console app:

_bstr_t strCnn("my database connection string");

with the database connection string hard coded as above, it works, i connect
to my db.

when i read the db connection string into a string

variable from the console
and try to use it or something i converted it into as the

argument to strCnn
I can't connect. Any help would be appreciated.

ps

I know _bstr_t is not part of standard C++, it's a C++

class from microsoft.

there's info on _bstr_t all over the web but i still can't

get my code to
work so i'm posting here.

<snip>

<OT>
Just out of morbid curiosity, what exactly happened when you
tried
string dasfk = "my database connection string";
const _bstr_t strCnn(dasfk.c_str());
</OT>


this works, i love you man


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet

News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 22 '05 #6

P: n/a
alex wrote:
bad news

string dasfk = "my database connection string";
const _bstr_t strCnn(dasfk.c_str());

the above works but when i use the string variable that took the console
input or assign that string variable to dasfk, it doesn't work. The error
message in this and most other cases is SQL Server does not exist or access
denied.

i know the variable has the connection string in it because i display it to
output after it's read in from the console.


Hint: Have you tried to look at the contents of your strings in the
debugger?

--
Peter Kragh
Jul 22 '05 #7

P: n/a
Please don't top-post.

alex wrote:
bad news

string dasfk = "my database connection string";
const _bstr_t strCnn(dasfk.c_str());

the above works but when i use the string variable that took the
console input or assign that string variable to dasfk, it doesn't
work. The error message in this and most other cases is SQL Server
does not exist or access denied.


It heavily depends on how _bstr_t works. Since many people here (like
me) don't know anything about that type, it's hard to give an accurate
answer. If the constructor of that class doesn't make a copy of the
string data, you might get into trouble. The pointer that c_str()
returns is only valid as long as the string is not modified or deleted.

Jul 22 '05 #8

P: n/a
alex wrote:
the above works but when i use the string variable that took the console
input or assign that string variable to dasfk, it doesn't work. The error
message in this and most other cases is SQL Server does not exist or access
denied.
It seems like the work of the comp.lang.c++ is done. I think your
chances of getting relevant change in this newsgroup have degraded
significantly.

Try an MS newsgroup.
i know the variable has the connection string in it because i display it to
output after it's read in from the console.

You can be mislead by console output.

Jul 22 '05 #9

P: n/a

"Jorge Rivera" <jo*****@rochester.rr.com> wrote in message
news:TV********************@twister.nyroc.rr.com.. .
alex wrote:
the above works but when i use the string variable that took the console
input or assign that string variable to dasfk, it doesn't work. The error message in this and most other cases is SQL Server does not exist or access denied.

It seems like the work of the comp.lang.c++ is done. I think your
chances of getting relevant change in this newsgroup have degraded
significantly.

Try an MS newsgroup.
i know the variable has the connection string in it because i display it to output after it's read in from the console.

You can be mislead by console output.


i've verified using breakpoints as well, the problem is the variable type, i
need to do proper conversion from console input and i haven't gotten the
conversion right.


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 22 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.