SQL Server instance port connection string

What's the format that server, instance, and port have to appear in a sql server connection string?

Thanks
gromulAsked:
Who is Participating?
 
imitchieConnect With a Mentor Commented:
then yup, DataSource=servername\instance,port is right

Provider=SQLOLEDB.1;Password=xxxx;Persist Security Info=True;User ID=xxxxx;Initial Catalog=mydbname;Data Source=servername\instance,port;
0
 
imitchieCommented:
Provider=SQLOLEDB.1;Password=xxxx;Persist Security Info=True;User ID=xxxxx;Initial Catalog=mydbname;Data Source=servername\instance
0
 
imitchieCommented:
If you want to connect on a non-standard port, you'll have to do that by creating a SQL alias in SQL Server Client Network Utility (Start->Run->CliConfg.exe),
and setting the port number there
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
gromulAuthor Commented:
Could I do something like this?

DataSource=servername\instance,port
0
 
imitchieCommented:
what application or IDE are you using?
0
 
gromulAuthor Commented:
I want to set up a connection string from C# code.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
note: unless your sql server has been changed to use the non-default port, you can leave the port information out of the connection string.
only in an environment where the sql server port has been changed for security it must be specified...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.