'' There is a full example server using Visual Basic and connects to the '' Northwind sample database included in the SkyWire COM Server install. '' This server shows how you can extend SkyWire servers with full database '' support and also has examples of custom methods that implement business '' logic on the server. '' Starting the Server '' A server must listen on a certain port and be set to active and also '' connect to a database. Set AstaServer = New CAstaCOMServer Set Conn = New Connection Set Tbl = New Recordset Conn.Open "ODBC;DATABASE=NorthWind;UID=;PWD=;DSN=NorthWind;" AstaServer.Port = 9090 AstaServer.SecureServer = True AstaServer.Active = True '' Authentication a Username and password is presented from remote clients. Private Function AstaServer_OnAuthenticate(ByVal Username As String, ByVal Password As String) As Boolean AstaServer_OnAuthenticate = True End Function '' Converting a RecordSet to a CAstaRecordSet Private Sub DoDataListSelect(SQL As String, StartRecord As Integer, RowCount As Integer, MaxLength As Integer, P As AstaCOMServer.ICAstaParamList) Dim RS As Recordset Dim AstaRS As CAstaRecordSet Dim x As Integer Set RS = New Recordset Set AstaRS = New CAstaRecordSet If Len(SQL) = 0 Then LogIt " 1011 Error - No SQL Specified" P.AddParam "Error", "No SQL Specified" Exit Sub End If On Error GoTo DoDataListSelectErrorHandler RS.Open SQL, Conn P.Clear '' Add Fields For x = 0 To RS.Fields.Count - 1 LogIt " fields " & RS.Fields(x).Name & RS.Fields(x).Type Select Case RS.Fields(x).Type Case adBSTR, adChar, adVarChar, adWChar, 202 AstaRS.AddField RS.Fields(x).Name, ftString, RS.Fields(x).DefinedSize Case 203 AstaRS.AddField RS.Fields(x).Name, ftString, 500 Case adCurrency, adDecimal, adDouble, adNumeric AstaRS.AddField RS.Fields(x).Name, ftFloat, 0 Case adDate, adDBDate, adDBTime, adbTimeStamp, 135 AstaRS.AddField RS.Fields(x).Name, ftDateTime, 0 Case adInteger, adSingle, adSmallInt AstaRS.AddField RS.Fields(x).Name, ftInteger, 0 Case Else AstaRS.AddField RS.Fields(x).Name, ftVariant, 0 End Select Next '' Data RS.MoveFirst RS.Move StartRecord AstaRS.Open While Not RS.EOF And RowCount > 0 AstaRS.AddNew For x = 0 To RS.Fields.Count - 1 AstaRS.FieldValue(RS.Fields(x).Name) = RS.Fields(x).Value Next AstaRS.Update RowCount = RowCount - 1 RS.MoveNext Wend AstaRS.DataSetToDataList 0, AstaRS.RecordCount, 32700, P AstaRS.Close RS.Close End Sub '' Handling Client Requests '' Client requests come in using a MsgToken that supports the SkyWireServer '' API or allows for some custom Business Logic to be implemented on the '' middle tier. Private Sub AstaServer_OnParamList(ByVal MsgID As Long, ByVal InParamList As AstaCOMServer.ICAstaParamList, OutParamList As AstaCOMServer.ICAstaParamList, ErrorCode As Long, ErrorMessage As String) Dim x As Integer Dim RowCount As Integer Select Case MsgID Case 1001 DoServerTime OutParamList Case 1003 UserDataSet.MoveFirst DoSelect InParamList.Params(0).AsString, OutParamList Case 1004 DoTables OutParamList Case 1005 For x = 0 To InParamList.Count - 1 LogIt "SQL ExecSQL 1005: " & InParamList.Params(x).AsString Next DoExecSQL OutParamList Case 1006 DoTableFields OutParamList Case Else DoServerTime OutParamList End Select End Sub