How to Get Connection String of Sql Server for Vb.Net



How to Get Connection String of Sql Server for Vb.Net


What is Connection String?

Connection string is the address you provide to your Vb.net form so it can communicate with SQL Server.

How to Get Connection String”

There are two ways.
  • 1st Method (Easy but long)
  • 2nd Method (Short and Easy)

First I will tell you the way I find easy.

1st Method (Easy but long).


  • Open notepad
  • Do not write anything in it. Just save it blank anywhere.
  • When saving it select “All Files” from “save as type” dropdown box.
  • In the end of your filename add “.UDL”(dot U+D+L).

It will look like this.
 




The right-click on the file and select “Open-with”
Select “Microsoft Data Access. OLE DB Core Service”



A Window will show up. Go to “Provider” tab and Select “Microsoft OLE DB Provider for SQL Server”. 

Then Click on Next. You will be switched to “Connection” Tab. In “Select or enter a server name” enter your Database complete name. Click on “Use Windows NT Integrated Security” if you use integrated security. But if you use password. The select the second option and enter password. Now finally select database from “Select the database on the server” you want to use.



Click on test connection. A message will Appear of you success. Click on Ok and open the same file (Any Name.UDL) with notepad. Find these word "Integrated Security=”. From the word Integrated copy whole line till the end. It will be something like this

"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Sample Database app By SH3HAN;Data Source=SH3HAN\SH3HAN"

Paste it in your vb.net coding section as your connection String.
That’s it!!


2nd Method (Short and Easy).

 
Just Remember this Line for server with windows integrated security (without password).

"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=datbase name here;Data Source=server name here"

And you are done.
 

0 comments:

Post a Comment

Powered by Blogger.