Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

How to connect sybase with excel vba?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Devon - 20 Jan 2006 09:00 GMT
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.
Bob Phillips - 20 Jan 2006 09:48 GMT
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

Signature

HTH

Bob Phillips

(remove nothere from email address if mailing direct)

> Hello, all,
>   Can you provide an example to illustrate how to connect sybase DB
[quoted text clipped - 3 lines]
>
> Devon.
Devon - 20 Jan 2006 15:14 GMT
Hello, Bob,
 Thank you for your great help, it works. I have searched this
solution for long time before.
Devon - 23 Jan 2006 14:16 GMT
If the following string also be OK?:
ConnString="Driver={Sybase
System};Srvr=ServerName;Db=abc;Uid=UserID;Pwd=UserPwd"
Bob Phillips - 25 Jan 2006 12:42 GMT
Not with ADO I don't think.

Signature

HTH

Bob Phillips

(remove nothere from email address if mailing direct)

> If the following string also be OK?:
> ConnString="Driver={Sybase
> System};Srvr=ServerName;Db=abc;Uid=UserID;Pwd=UserPwd"
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.