Common Practice to Connect SQL

G

Guest

I'd like to ask for the correct way, or rather say the more advisable way to
connect to a SQL Server in a Windows application written in .NET 1.1 or 2.0.
When I develop my program, the database is located on my machine. But when it
is published, the database that it use will be on our server. My practice is
to write a class, storing the credentials and information needed to connect
to the database. And create the DataAdapter by coding (instead of dragging
the DataAdapter to the form from Tools) in the class. Which should be the
common practice to be advised?
 
M

Miha Markic

Connection string belongs to configuration file or in registry (note that
you have to encrypt it if contains sensitive information)
You would use that connection string to create any connection you need.
 
W

William \(Bill\) Vaughn

One approach that I discuss in my book is to obfuscate the server/instance
with a registered Alias. This way you can change the targeted server at
will. Yes, it might be important to hide the credentials, but I often create
an account on the server with very limited rights for use by a specific
application type.

--
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest books:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and
Hitchhiker's Guide to SQL Server 2005 Compact Edition
 
G

Guest

May I ask how do you create a registered Alias?

William (Bill) Vaughn said:
One approach that I discuss in my book is to obfuscate the server/instance
with a registered Alias. This way you can change the targeted server at
will. Yes, it might be important to hide the credentials, but I often create
an account on the server with very limited rights for use by a specific
application type.

--
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest books:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and
Hitchhiker's Guide to SQL Server 2005 Compact Edition
 
W

William \(Bill\) Vaughn

Sure, use the SQL Server configuration manager applet. Click on "SQL Native
Client Configuration" and choose "Alias". Fill in the dialog with the Server
as the machine name\instance and an alias name.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
 
W

William \(Bill\) Vaughn

It's installed with SQL Server.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
 
G

Guest

Sorry, I still can't find it. Is it at SQL Server Client Network Utility? Or
can I find it from Enterprise Manager?
 
W

William \(Bill\) Vaughn

Ah, in SQL Server 2000, it's the SS Client Network Utility. I thought you
were running 2005.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
 
G

Guest

Ok, I have added the alias at Client Network Utility, and registered at the
Enterprise Manager. However, when I go to Visual Studio 2005, my project, I
look at the Server Explorer, the database that I registered did not appear,
no matter how many times I refresh... Were what I did correct?
 
W

William \(Bill\) Vaughn

It won't appear on its own. To use the alias, you need to create a Database Connection in the server explorer and set "Server" to the alias instead of the machine\instance designation.




--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
 

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