|
Article relates to
|
RadScheduler
|
|
Created by
|
Peter, Telerik
|
|
Last modified
|
June 30, 2008
|
|
Last modified by
|
Peter, Telerik
|
HOW TO
Use RadScheduler with AcessDataSource
DESCRIPTION
This KB describes how to:
1. Create a simple access data base from scratch;
2. Create an AccessDataSource and bind RadScheduler to it;
3. Troubleshoot the "You tried to assign the Null value to a variable that is not a Variant data type." error;
SOLUTION
Part I - Create a simple access data base from scratch
Using the
Database structure help topic as reference, create the following access table and name it "Appointments":
Save this data source in the
App_Data folder of your project as
scheduler1.
mdb
Part II - Create an AccessDataSource and bind RadScheduler to it
1. At Design-time, using RadScheduler's smart tag go to "Chose Data Source..." and follow the steps from the screenshot below:
2. Choose the
scheduler1.mdb from the
App_Data folder:
3. Generate Select, Update, Delete and Insert statements automatically:
4. Set RadScheduler's data field properties to the corresponding columns in the access data table:
Part III - Troubleshoot the "You tried to assign the Null value to a variable that is not a Variant data type." error
If you run the project at this point you will get the "You tried to assign the Null value to a variable that is not a Variant data type." error. This is because the auto generated Insert command has a flaw which we will have to fix manually. Basically, this error is telling us that a null value has been attempted to be inserted in the autonumber ID column. The solution is to remove the ID field from the Insert statement. Deleting the highlighted parts below(3) will resolve the problem:
| <asp:AccessDataSource ID="AccessDataSource1" runat="server" |
| DataFile="~/App_Data/scheduler1.mdb" |
| DeleteCommand="DELETE FROM [Appointments] WHERE [ID] = ?" |
| InsertCommand="INSERT INTO [Appointments] ([ID], [Subject], [Start], [End], [RecurrenceRule], [RecurrenceParentID]) VALUES (?, ?, ?, ?, ?, ?)" |
| SelectCommand="SELECT * FROM [Appointments]" |
| UpdateCommand="UPDATE [Appointments] SET [Subject] = ?, [Start] = ?, [End] = ?, [RecurrenceRule] = ?, [RecurrenceParentID] = ? WHERE [ID] = ?"> |
| <DeleteParameters> |
| <asp:Parameter Name="ID" Type="Int32" /> |
| </DeleteParameters> |
| <UpdateParameters> |
| <asp:Parameter Name="Subject" Type="String" /> |
| <asp:Parameter Name="Start" Type="DateTime" /> |
| <asp:Parameter Name="End" Type="DateTime" /> |
| <asp:Parameter Name="RecurrenceRule" Type="String" /> |
| <asp:Parameter Name="RecurrenceParentID" Type="Int32" /> |
| <asp:Parameter Name="ID" Type="Int32" /> |
| </UpdateParameters> |
| <InsertParameters> |
| <asp:Parameter Name="ID" Type="Int32" /> |
| <asp:Parameter Name="Subject" Type="String" /> |
| <asp:Parameter Name="Start" Type="DateTime" /> |
| <asp:Parameter Name="End" Type="DateTime" /> |
| <asp:Parameter Name="RecurrenceRule" Type="String" /> |
| <asp:Parameter Name="RecurrenceParentID" Type="Int32" /> |
| </InsertParameters> |
| </asp:AccessDataSource> |
Please, refer to the attached demo project.
Please
Sign In
to rate this article.