Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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" wrote in message
oups.com...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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=User Pwd"

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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" wrote in message
oups.com...
If the following string also be OK?:
ConnString="Driver={Sybase
System};Srvr=ServerName;Db=abc;Uid=UserID;Pwd=User Pwd"



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel cannot connect to web Ltat42a Excel Discussion (Misc queries) 0 May 29th 06 05:18 PM
Data Conversion into Sybase jagluski Excel Discussion (Misc queries) 1 December 16th 04 05:12 PM
Excel Query Via Sybase Gary Excel Discussion (Misc queries) 1 December 7th 04 07:58 PM
Export data from Sybase into Excel 2003 Ray[_13_] Excel Programming 0 October 13th 04 07:53 PM
ODBC error linking to Sybase database budda[_2_] Excel Programming 0 November 12th 03 07:16 PM


All times are GMT +1. The time now is 09:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"