CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Oct 2000
    Location
    India
    Posts
    25

    How To Specify MS -SQL Server port number in Connection String

    Hi,
    I am trying to establish a connection with MS SQL server database. To do this I form a Connection String. In the connection String I specify the Database server name, User name and Password. Till this it is fine.
    But my problem is I also want to specify the port number. by default it is 1433 for SQL Server, but what if SQL Server is running on some other port number. Then how do I specify this port number in Connection String?

    Thanks,
    Dipesh


  2. #2
    Join Date
    Sep 2001
    Location
    Little Rock, Arkansas
    Posts
    40

    Re: How To Specify MS -SQL Server port number in Connection String

    http://www.able-consulting.com/ADO_Conn.htm

    To connect to SQL Server running on a remote computer (via an IP address):

    oConn.Open "Driver={SQL Server};" & _
    "Server=xxx.xxx.xxx.xxx;" & _
    "Address=xxx.xxx.xxx.xxx,1433;" & _
    "Network=DBMSSOCN;" & _
    "Database=myDatabaseName;" & _
    "Uid=myUsername;" & _
    "Pwd=myPassword;"
    Where:
    - xxx.xxx.xxx.xxx is an IP address
    - 1433 is the default port number for SQL Server.
    - "Network=DBMSSOCN" tells ODBC to use TCP/IP rather than Named Pipes (Q238949)



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured