1)
When you set the CalendarControl.SetDataProvider "Provider=custom;" what happens is that the CalendarControl will RaiseEvents like DoCreatexxx, DoReadxxx etc. You need to intercept these events and read or write to your SQLServer connection.
Here is a link to: http://www.connectionstrings.com - http://www.connectionstrings.com where you can find many more sample connection strings
Look at the OpenProvider function in frmMain and change to the following... Public Sub OpenProvider(ByVal eDataProviderType As CodeJockCalendarDataType, ByVal strConnectionString As String) dim strConnect As String
'Here is a connection string to a sql server database. strConnect="" strConnect= strConnect & ""Provider=SQLOLEDB;" strConnect= strConnect & "Driver={SQL Server};" strConnect= strConnect & "Integrated_Security=False;" strConnect= strConnect & "Persist Security Info=false;" strConnect= strConnect & "Connect Timeout=30;" strConnect= strConnect & "DataTypeCompatibility=80;" strConnect= strConnect & "Trusted Connection=false;" strConnect= strConnect & "Application Name= My_ApplicationName;" strConnect= strConnect & "Network=DBMSSOCN;(Local)\SQLEXPRESS,1455;" strConnect= strConnect & "User ID=MyUser_ID;" strConnect= strConnect & "Password=MyUser_Password;" strConnect= strConnect & "Initial Catalog=MySQLServer_Database;"
Set m_pCustomDataHandler = Nothing ' SQL Server provider Set m_pCustomDataHandler = New providerSQLServer m_pCustomDataHandler.OpenDB strConnect m_pCustomDataHandler.SetCalendar CalendarControl CalendarControl.SetDataProvider "Provider=custom;" If eDataProviderType = cjCalendarData_SQLServer Or eDataProviderType = cjCalendarData_MySQL Then CalendarControl.DataProvider.CacheMode = xtpCalendarDPCacheModeOnRepeat End If If Not CalendarControl.DataProvider.Open Then CalendarControl.DataProvider.Create End If m_eActiveDataProvider = eDataProviderType CalendarControl.Populate wndDatePicker.RedrawControl
End Sub
In the providerSQLServer class change the OpenDB function to...
Public Sub OpenDB(ByVal strConnection As String) On Error GoTo err1 m_Connection.Open strConnection m_bOpened = True
err1: If Err.Number <> 0 Then m_bOpened = False MsgBox "Cannot open SQL Server DB: " & Err.Description End If End Sub
2)
You will need to create the tables and fields in in your sql server database yourslef. I have not tested if the following in the OpenProvider function will create the tables if you are connected to a sql server database.
If Not CalendarControl.DataProvider.Open Then CalendarControl.DataProvider.Create End If
You might want to try and see for yourself.
|