Serving the Quantitative Finance Community

 
User avatar
NewtoRisk
Topic Author
Posts: 0
Joined: February 17th, 2006, 11:37 am

connection to sybase

June 23rd, 2006, 10:56 am

hi thereI would like to connect to a sybase server via vba in XL so I can return some dataI have the following code but Im not sure how to open the connection since I have only used the code to connect to access beforeany help will be appreciated Public Function arraysql()Dim cmd As ADODB.Command, mysql As String, rs As ADODB.Recordset, I As Long, conn As ADODB.Connectionmysql = strsqlSet conn = New ADODB.ConnectionSet cmd = New ADODB.Command====How do I call the sybase server ????conn.Open With cmd .ActiveConnection = conn .CommandText = mysql .CommandType = adCmdText .ExecuteEnd WithSet rs = New ADODB.Recordsetrs.Open cmd, , adOpenKeyset, adLockOptimistic'// store the recordset into a variant-type array'// array is dimensioned by (number of fields) x (number of records)fldArray = rs.GetRows()arraysql = fldArray'For i = 0 To UBound(fldArray, 2)'Debug.Print fldArray(0, i)'NextEnd Function
 
sjoo
Posts: 0
Joined: March 24th, 2003, 1:54 am

connection to sybase

June 23rd, 2006, 11:15 am

Hi, You need to pass a connection string to Open method of the ADODB Connection object(in your case, conn)how to get a connection string is very easy.Plz. refer to UDL Tutorialor Making Connection...In short 1.create a blank text file(eg., create sybase.txt using NOTEPAD.exe)2.Rename extension of file(eg., sybase.udl )3.doule-click and open it4.you will see a dialog box , "Data Link Properties"5.In [Provider] tab, specify sybase~provider~ if you can't see that, install database driver. 6.In [Connection] tab, input Data source,Location,ID,Password, etc7.Click [Test Connection] 8.If you succeed, Open the udl file using the NOTEPAD.exe9.You'll see a connection string.10.copy the string and paste on your source codeHTH,sjoo
 
User avatar
NewtoRisk
Topic Author
Posts: 0
Joined: February 17th, 2006, 11:37 am

connection to sybase

June 23rd, 2006, 3:02 pm

thank you