473,399 Members | 4,177 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,399 software developers and data experts.

string conversion problems

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
9 1117
"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
"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
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

"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
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
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
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
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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: John van Terheijden | last post by:
Hi. I'm trying to make a conversion algorithm that colors even and odd words in a HTML string with <div> tags. // input text with all sorts of HTML tags and whitespace $str = "<h1>Title...
0
by: Christophe Elek | last post by:
Ok, I am completly at lost :) in both cases (my Yenc and zip utilities) i try to do the following 1) get a String 2) transform in byte 3) so some computation (either adding value to the byte...
31
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one...
1
by: Rick Knospler | last post by:
I am trying to convert a vb6 project to vb.net. The conversion worked for the most part except for the fixed length strings and fixed length string arrays. Bascially the vb6 programmer stored all...
14
by: nishit.gupta | last post by:
Is their any single fuction available in C++ that can determine that a string contains a numeric value. The value cabn be in hex, int, float. i.e. "1256" , "123.566" , "0xffff" , It can also...
10
by: v4vijayakumar | last post by:
1. why the following program is not working as expected? #include <iostream> using namespace std; int main() { string t("test"); wcout << (wchar_t *) t.c_str() << endl; wcout << t.c_str()...
10
by: Dancefire | last post by:
Hi, everyone, I'm writing a program using wstring(wchar_t) as internal string. The problem is raised when I convert the multibyte char set string with different encoding to wstring(which is...
21
by: phpCodeHead | last post by:
Code which should allow my constructor to accept arguments: <?php class Person { function __construct($name) { $this->name = $name; } function getName()
20
by: karthikbalaguru | last post by:
Hi, String constant being modifiable in C++ but, not modifiable in C. that is, In C++, the following example output will be "Mplusplus" char *str1 = "Cplusplus"; *str1 = 'M'; In C, the above...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
agi2029
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,...
0
isladogs
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...

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.