Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

C++ Builder:   open file by command line and inputBox

Posted on 2001-08-02
9
Medium Priority
?
718 Views
Last Modified: 2012-06-27

DBTable->DatabaseName=AnsiString InputBox"("File routine","routine","C:\");
DBTable->TableName=InputBox"("Filename","filename","filename");
DBTable->Open();

________________________
Above code dose not work. Below code work, but the filename can not be modified during running. How to modify above code?
________________________


DBTable->DatabaseName="c:\\temp\\temp2";
DBTable->TableName="temp.db";
DBTable->Open();
0
Comment
Question by:Johncili
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 30

Accepted Solution

by:
Axter earned 100 total points
ID: 6346466
>>Above code dose not work.
Exactly what does not work.  Please give details.

Try the following for the lower code:

char data1[] = "c:\\temp\\temp2";
char data2[] = "temp.db";
DBTable->DatabaseName=data1;
DBTable->TableName=data2;
0
 
LVL 22

Expert Comment

by:nietod
ID: 6346477
DBTable->DatabaseName=InputBox"("File routine","routine","C:\");

should be

DBTable->DatabaseName=AnsiString InputBox"("File routine","routine","C:\\");

the \ character is an escape character and it is treated specially in a string literal.  If you wish to include a single \ in a string, you must actually write two \s.  this does not cause two \s to be stored, only one.  

Also note that there was an extra "AnsiString" stuck in there.
0
 

Author Comment

by:Johncili
ID: 6346516
Still it did not work.

DBTable->DatabaseName=AnsiString InputBox("File routine","routine","C:\\");

I just want to pop-up an input box, and the filename can be input.

Any one know?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 30

Expert Comment

by:Axter
ID: 6346527
You still AnsiString after the equal sign.

See nietod's comment.
0
 
LVL 22

Expert Comment

by:nietod
ID: 6346544
its that extra "AnsiString" in the middle of the line.

I'm not sure why you think you need it.  it is like doing

int x = 5;
int y = int x; // ERROR

You don't want that "int" thrown in before the "x" on the 2nd line.

On the 2nd line the compiler knows that x is an int.

In your code, the compilers knows that InputBox() returns an AnsiString..
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6347406
better use
..AnsiString InputBox("File routine","routine","");

0
 

Expert Comment

by:sant3000
ID: 6347881
hello, the real problem is what u can't modify DatabaseName in runtime...so, u have only one way to avoid this problem.. delete DBTable object and create new one with modified DatabaseName
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6349449
O, of course you can't change name during Databas is opened
Yur must close every
connection to the database before change the path. The code will look
something like : (example change ODBC name)

LoginDatabase->Close();

ODBC ODBCChange;
/*
 Don't forget that the name ODBC_NAME must be the same as under wich you
 created it
 */
 ODBCChange.ChangePath("ODBC_NAME","c:\\database.mdb");
 
 LoginDatabase->LoginPrompt=false;
 LoginDatabase->DatabaseName = "ODBC_NAME";
 LoginDatabase->KeepConnection = true;
 LoginDatabase->Open();



0
 
LVL 30

Expert Comment

by:Axter
ID: 6360540
Johncili,
A C grade???
Ooch, that hurts...

I notice that you have the following grading record:
C C C B

Most questions should be given an 'A' grade, unless the expert fails to answer any additional questions.

If you continue to grade answers with C's and B's, experts will not want to help you in the future.

Experts do not get paid for helping you.  Please show your graditue by giving them the grade they deserve.

Thank you for the points, but in the future, please be gentel with my grading record.

Thank you
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

647 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question