473,405 Members | 2,160 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,405 software developers and data experts.

console io

i'm writing a console app using unmanaged c++ that uses cout/cin to request
a few database connection strings and read them into some string variables.
The problem is: after the frist db connection string is entered, the next
set of cout/cin statements is run thru without giving the user a chance to
input the second db connection string the app requires. I think this is
happening because the database connection strings i'm using have semi-colons
(;) in them (name-value pairs separated by semicolons). If I put in simple
strings like adsfkadsf asdflkjads, the io works as expected. I'm pretty sure
the problem is the semi-colons but don't know what to do about it. There are
also equal signs (=) and single quotes (') in the db connection strings.
Anybody know anything about this?

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
6 1712

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
i'm writing a console app using unmanaged c++ that uses cout/cin to request a few database connection strings and read them into some string variables. The problem is: after the frist db connection string is entered, the next
set of cout/cin statements is run thru without giving the user a chance to
input the second db connection string the app requires. I think this is
happening because the database connection strings i'm using have semi-colons (;) in them (name-value pairs separated by semicolons). If I put in simple
strings like adsfkadsf asdflkjads, the io works as expected. I'm pretty sure the problem is the semi-colons but don't know what to do about it. There are also equal signs (=) and single quotes (') in the db connection strings.
Anybody know anything about this?


I doubt your reasoning is correct. I expect the problem is that you are
mixing numeric and string input incorrectly. That is the usual reason for
this error. But, of course, its impossible to help you fix this problem
because you neglected to post any code.

Post the code and it will get sorted out very quickly.

john
Jul 22 '05 #2
Provider='sqloledb';Data Source='OKSANA\\OKSANA';Initial
Catalog='pubs';Integrated Security='SSPI';User ID=sa;Password=session99
"John Harrison" <jo*************@hotmail.com> wrote in message
news:2h************@uni-berlin.de...

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
i'm writing a console app using unmanaged c++ that uses cout/cin to

request
a few database connection strings and read them into some string

variables.
The problem is: after the frist db connection string is entered, the next set of cout/cin statements is run thru without giving the user a chance to input the second db connection string the app requires. I think this is
happening because the database connection strings i'm using have

semi-colons
(;) in them (name-value pairs separated by semicolons). If I put in simple strings like adsfkadsf asdflkjads, the io works as expected. I'm pretty

sure
the problem is the semi-colons but don't know what to do about it. There

are
also equal signs (=) and single quotes (') in the db connection strings.
Anybody know anything about this?


I doubt your reasoning is correct. I expect the problem is that you are
mixing numeric and string input incorrectly. That is the usual reason for
this error. But, of course, its impossible to help you fix this problem
because you neglected to post any code.

Post the code and it will get sorted out very quickly.

john


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 #3

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
Provider='sqloledb';Data Source='OKSANA\\OKSANA';Initial
Catalog='pubs';Integrated Security='SSPI';User ID=sa;Password=session99


Well that's the input, but where's the code?

Clearly your problem isn't with mixing numeric and string input because
there isn't any numeric input above. Nevertheless its impossible to help you
with bugs in your code without seeing the code.

john
Jul 22 '05 #4
after i enter my connect string in response to the first cout, the rest of
the code gets run thru with no stops

if i just enter a simple string like asdfjdasfadsd the code behaves normally

string targetConnectString, repositoryConnectString, tmpStr;

cout << "enter target connection string: ";

cin >> targetConnectString;

cout << '\n'

<< "enter repository connection string: ";

cin >> repositoryConnectString;

cout << '\n';

"John Harrison" <jo*************@hotmail.com> wrote in message
news:2h************@uni-berlin.de...

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
Provider='sqloledb';Data Source='OKSANA\\OKSANA';Initial
Catalog='pubs';Integrated Security='SSPI';User ID=sa;Password=session99
Well that's the input, but where's the code?

Clearly your problem isn't with mixing numeric and string input because
there isn't any numeric input above. Nevertheless its impossible to help

you with bugs in your code without seeing the code.

john


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

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
after i enter my connect string in response to the first cout, the rest of
the code gets run thru with no stops

if i just enter a simple string like asdfjdasfadsd the code behaves normally
string targetConnectString, repositoryConnectString, tmpStr;

cout << "enter target connection string: ";

cin >> targetConnectString;

cout << '\n'

<< "enter repository connection string: ";

cin >> repositoryConnectString;

cout << '\n';


Well the problem is that you have spaces in your connection string, this

cin >> targetConnectString;

will stop reading at the first space. The next read will start where the
last one ended, which is why it doesn't stop, its still reading what you
entered last time.

If you want to read a line at a time use getline.

getline(cin, targetConnectString);
getline(cin, repositoryConnectString);

john
Jul 22 '05 #6
that worked! you rule.

"John Harrison" <jo*************@hotmail.com> wrote in message
news:2h************@uni-berlin.de...

"alex" <al*************@verizon.net> wrote in message
news:40**********@127.0.0.1...
after i enter my connect string in response to the first cout, the rest of the code gets run thru with no stops

if i just enter a simple string like asdfjdasfadsd the code behaves

normally

string targetConnectString, repositoryConnectString, tmpStr;

cout << "enter target connection string: ";

cin >> targetConnectString;

cout << '\n'

<< "enter repository connection string: ";

cin >> repositoryConnectString;

cout << '\n';


Well the problem is that you have spaces in your connection string, this

cin >> targetConnectString;

will stop reading at the first space. The next read will start where the
last one ended, which is why it doesn't stop, its still reading what you
entered last time.

If you want to read a line at a time use getline.

getline(cin, targetConnectString);
getline(cin, repositoryConnectString);

john


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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method:...
1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
7
by: shawnk | last post by:
Hello Everyone How do you format format numbers right-justified using Console.WriteLine(), i.e I need to line up numbers in vertical columns and the MSDN documentation is pretty poor Here is the...
5
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough...
5
by: Publicjoe | last post by:
I am working on a little app which uses colour in the console window. I have created a class to extend the console functionality but the ClearScreen method does not work correctly. I am enclosing a...
17
by: MumboJumbo | last post by:
Hi I have a really basic question hopefully some can help me with: Can you write a (i.e. one) C# project that works from the cmd line and gui? I seems if i write a GUI app it can't write to...
5
by: portroe | last post by:
Hi I am using console.Writeline in my simple program. I do not however see anything happening in the output window when I debug, there are also no error messages, Has anybody a tip on what...
3
by: julianmoors | last post by:
Hey, Currently I'm writing a VB.NET/1.1 app and I need to mask the input for the password field. Does anyone know how to do this in VB? I've seen a C# example, but wouldn't know how to convert...
6
by: tony | last post by:
Hello! When you have windows forms you have the same possibility as when you have a Console application to use Console.Writeln to write whatever on the screen. Now to my question: Is it...
1
by: John Wright | last post by:
I am running a console application that connects to an Access database (8 million rows) and converts it to a text file and then cleans and compacts the database. When it runs I get the following...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
tracyyun
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...

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.