passing parameter to class from application

S

Smile

Hi there,

I have a question, please give me some idea. Thanks in advance!

Solution1
|
|---DBLogic (class library)
| |
| |-dblogic (class) which defines ConnString, functions to create
DataTable by sqlstr
|
|
|---DBObjects (class library)
| |
| |-dbClients
| |
| |-dbEmployees.. etc
|
|
|---UI (main application/start project)
| |
| |-Forms and UI
| |-StartForm

my questions is, the ConnString is hard-coded in the DBLogic class, with
"server = xxx; database=xxxx; uid=sa; pwd=sapass", as said by the book i am
reading,

is it possible for me to read-in a text file with the UI\StartForm, and pass
those
information to dblogic class? and howto?

i am doing that way becuase i want to modify the sa password from time to
time, so
that all i have to change is the text file after change the sa's password.

Thanks again.


Smile
 
R

RobinS

You should not hardcode the connection string in your program.
You should store it in the Application Settings for the Project
containing the Data Access Component. There is a Type field of
ConnectionString.

Then when you want to change it, you can change it in that one
place. And when you want to access it, you know where it is.

If you're using VB, you can then put it in your code as
My.Settings.MyConnectionString instead of the actual connection
string, and it will go get it from the settings file.

If you're not using VB, there's some way to get that connection
string out of the application settings, but I don't know what
it is. If you're using C#, re-post and ask for that info.

Also, it's *much* safer to set up your SQLServer database to
use Windows authentication, so you don't have a username and
password hardcoded anywhere.

Robin S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top