Results 1 to 3 of 3

Thread: MS SQL Connectionstring

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    16

    MS SQL Connectionstring

    Hello Guys,

    I'm using eVB 3.0 and backend MS MSQL, does anyone know the right connectionstring of MS SQL so I can connect to the server using ADOCE 3.1? Thanks

  2. #2
    New Member
    Join Date
    Jan 2005
    Posts
    6

    Re: MS SQL Connectionstring

    Quote Originally Posted by gilkaths
    Hello Guys,

    I'm using eVB 3.0 and backend MS MSQL, does anyone know the right connectionstring of MS SQL so I can connect to the server using ADOCE 3.1? Thanks
    For eMbedded Visual Basic 3.0 MS SQL I not tested becouse I don't use MSSQL, but connection I think no differents from VB6 and it can work, maybe not?:]

    Tray it:
    VB Code:
    1. ' eMbedded Visual Basic 3.0
    2. Option Explicit
    3.  
    4. Private oConn As ADOCE.Connection
    5.  
    6. Private Sub cmdTest_Click()
    7. 'ODBC Driver for SQL Server
    8. 'For Standard Security
    9.  
    10. oConn.Open "Driver={SQL Server};" & _
    11.            "Server=MyServerName;" & _
    12.            "Database=myDatabaseName;" & _
    13.            "Uid=myUsername;" & _
    14.            "Pwd=myPassword"
    15.  
    16. 'For Trusted Connection security
    17.  
    18. oConn.Open "Driver={SQL Server};" & _
    19.            "Server=MyServerName;" & _
    20.            "Database=myDatabaseName;" & _
    21.            "Uid=;" & _
    22.            "Pwd="
    23. ' Or
    24. oConn.Open "Driver={SQL Server};" & _
    25.            "Server=MyServerName;" & _
    26.            "Database=myDatabaseName;" & _
    27.            "Trusted_Connection=yes"
    28.  
    29. 'To Prompt user for username and password
    30.  
    31. oConn.Properties("Prompt") = adPromptAlways
    32. oConn.Open "Driver={SQL Server};" & _
    33.            "Server=MyServerName;" & _
    34.            "DataBase=myDatabaseName"
    35.  
    36. 'To connect to SQL Server running on the same computer
    37.  
    38. oConn.Open "Driver={SQL Server};" & _
    39.            "Server=(local);" & _
    40.            "Database=myDatabaseName;" & _
    41.            "Uid=myUsername;" & _
    42.            "Pwd=myPassword"
    43.  
    44. 'To connect to SQL Server running on a remote computer (via an IP address)
    45.  
    46. oConn.Open "Driver={SQL Server};" & _
    47.            "Server=xxx.xxx.xxx.xxx;" & _
    48.            "Address=xxx.xxx.xxx.xxx,1433;" & _
    49.            "Network=DBMSSOCN;" & _
    50.            "Database=myDatabaseName;" & _
    51.            "Uid=myUsername;" & _
    52.            "Pwd=myPassword"
    53. 'Where:
    54. '- xxx.xxx.xxx.xxx is an IP address
    55. '- 1433 is the default port number for SQL Server.
    56. '- "Network=DBMSSOCN" tells ODBC to use TCP/IP rather than Named
    57. '   Pipes (Q238949)
    58.  
    59. End Sub
    60.  
    61. Private Sub Form_OKClick()
    62.     App.End
    63. End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    16

    Re: MS SQL Connectionstring

    Thanks for the info. But I tried your examples, an error occured. "The specified table does not exist", but I double check the server, I have that kind of table. I'll post the code I made. A simple code to connect to MS SQL server using eVB 3.0.

    Option Explicit

    Private Sub Form_Load()
    Dim rs As ADOCE.Recordset
    Dim constr As String
    Dim i As Integer
    Set cn = CreateObject("adoce.connection.3.1")
    Set rs = CreateObject("adoce.recordset.3.1")
    constr = "Driver={SQL Server};Server=testServer;Database=Testing;Uid=try;Pwd=test"
    i = 1
    mainGrid.Rows = 1
    rs.Open "select * from product", constr
    If Not rs.EOF Then
    rs.MoveFirst
    Do While Not rs.EOF
    mainGrid.TextMatrix(i, 0) = rs(0)
    mainGrid.TextMatrix(i, 1) = rs(1)
    mainGrid.Rows = mainGrid.Rows + 1
    i = i + 1
    rs.MoveNext
    Loop
    End If
    rs.Close

    End Sub

    Private Sub Form_OKClick()
    App.End
    End Sub

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