+ Reply to Thread
Results 1 to 5 of 5

How to connect sybase with excel vba?

  1. #1
    Devon
    Guest

    How to connect sybase with excel vba?

    Hello, all,
    Can you provide an example to illustrate how to connect sybase DB
    with excel vba. I'll appreicate any reply for this thread.

    Thanks.

    Devon.


  2. #2
    Bob Phillips
    Guest

    Re: How to connect sybase with excel vba?

    Sub GetData()
    Const adOpenForwardOnly As Long = 0
    Const adLockReadOnly As Long = 1
    Const adCmdText As Long = 1
    Dim oRS As Object
    Dim sConnect As String
    Dim sSQL As String
    Dim ary

    sConnect = "Provider=Sybase.ASEOLEDBProvider;" & _
    "Srvr=myASEServer,5000;" & _
    "Catalog=myDBName;" & _
    "User Id=myUser;" & _
    "Password=myPassword"

    'this assumes Sybase Adaptive Server 12.5
    '5000 is the port number
    'change the DBName, UserName & Password to suit

    sSQL = "SELECT * From Contacts"
    Set oRS = CreateObject("ADODB.Recordset")
    oRS.Open sSQL, sConnect, adOpenForwardOnly, _
    adLockReadOnly, adCmdText

    ' Check to make sure we received data.
    If Not oRS.EOF Then
    ary = oRS.getrows
    MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0)
    Else
    MsgBox "No records returned.", vbCritical
    End If

    oRS.Close
    Set oRS = Nothing
    End Sub


    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Devon" <[email protected]> wrote in message
    news:[email protected]...
    > Hello, all,
    > Can you provide an example to illustrate how to connect sybase DB
    > with excel vba. I'll appreicate any reply for this thread.
    >
    > Thanks.
    >
    > Devon.
    >




  3. #3
    Devon
    Guest

    Re: How to connect sybase with excel vba?

    Hello, Bob,
    Thank you for your great help, it works. I have searched this
    solution for long time before.


  4. #4
    Devon
    Guest

    Re: How to connect sybase with excel vba?

    If the following string also be OK?:
    ConnString="Driver={Sybase
    System};Srvr=ServerName;Db=abc;Uid=UserID;Pwd=UserPwd"


  5. #5
    Bob Phillips
    Guest

    Re: How to connect sybase with excel vba?

    Not with ADO I don't think.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Devon" <[email protected]> wrote in message
    news:[email protected]...
    > If the following string also be OK?:
    > ConnString="Driver={Sybase
    > System};Srvr=ServerName;Db=abc;Uid=UserID;Pwd=UserPwd"
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1