Common Practice to Connect SQL

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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.
 
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
 
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
 
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)
-----------------------------------------------------------------------------------------------------------------------
 
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)
-----------------------------------------------------------------------------------------------------------------------
 
Sorry, I still can't find it. Is it at SQL Server Client Network Utility? Or
can I find it from Enterprise Manager?
 
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)
-----------------------------------------------------------------------------------------------------------------------
 
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?
 
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)
-----------------------------------------------------------------------------------------------------------------------
 
Back
Top