I can create events, but changing an event or deleting one does not get saved to the database.
Suggestions?
Be sure that you have added dataprocessor initialization
Do you mean I should download dhtmlx.com/docs/download/dhtmlxConnector_net.zip?
Like I said, I can create events, just cannot change them. So, I do have a connection to the database. Do I still need the connector?
This is the save.ashx code. Do you see something wrong with it?
<%@ WebHandler Language=“VB” Class=“Save” %>
Imports System.Web
Imports System.Web.Services
Imports DHTMLX.Common
Public Class Save
Implements System.Web.IHttpHandler
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "text/xml"
Dim action = New DataAction(context.Request.Form)
Dim data As New DataClassesDataContext()
Try
Dim changedEvent = DirectCast(DHXEventsHelper.Bind(GetType([Event]), context.Request.Form), [Event])
Select Case action.Type
Case DataActionTypes.Insert
data.Events.InsertOnSubmit(changedEvent)
Exit Select
Case DataActionTypes.Delete
changedEvent = data.Events.SingleOrDefault(Function(ev) ev.id = action.SourceId)
data.Events.DeleteOnSubmit(changedEvent)
Exit Select
Case Else
' "update"
Dim eventToUpdate = data.Events.SingleOrDefault(Function(ev) ev.id = action.SourceId)
DHXEventsHelper.Update(eventToUpdate, changedEvent, New List(Of String)() From {"id"})
Exit Select
End Select
data.SubmitChanges()
action.TargetId = changedEvent.id
Catch a As Exception
action.Type = DataActionTypes.[Error]
End Try
context.Response.Write(New AjaxSaveResponse(action).ToString())
End Sub
ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
So, the sample application you sent me only creates events? I need to download and program something called the connector? Any instruction for that in VB.NET for webforms?
Hello,
I suppose you run Scheduler.ASP.NET.VB project from a samples package. I’ve just ran it locally - adding/updating/deleting events works right away, it does not require any additional configuration.
Some changes may be needed is you run application from IIS server - you need to ensure that the database connection is correct, and that data model classes matches the schema of the events table (in case you’ve changed it or created manually)
The package goes with the separete .mdf databases. In most cases you’ll need to attach database to MSSQL server in order to use it, and then modify the connection string appropriately.
If your mssql account don’t have permissions for attaching databases, you’ll need to create a table in the database you have access to.
In this case, you can copy the events table that goes with the attached database and create it on a remove sql server.
- attach mdf to your local database on MSSQL Management Studio,
- open the database and select a table,
- right click on the table -> Script Table As -> CREATE TO
- copy the generate SQL query
- then execute it in a remote database to create an events table there
After it’s done, you’ll have fully working application (given that the connection string is correct)
Another way is to create event table manually, the sample structure is described here
scheduler-net.com/docs/loading_d … _structure
In this case you must note that the if the sample uses LinqToSQL database access (most of the samples currenlty does), you have to ensure that previously generated classes still matches the table schema. Since there is no strict requirements for a column types there may be variations like nullable or not nullable Date type, or ‘text’ vs ‘nvarchar’ for a description columns.
The most simple way to ensure that LinqToSql classes are still valid is following (this is recomended after any changes in a table structure)
- find .dbml file with the model classes - Data\Scheduler.dbml
- double click the file to open a Visual Designer
- remove the ‘Event’ class box
- drag and drop events table from the Solution Explorer to the visual designer in order to create new class from the database table
- if it’s needed - you can correct name of the class or a certain properties in order to make it match the previously generated ones
- rebuild the project
I added Data\Scheduler.dbml to the project. It did not help. Still not able to change existing events.
In “Save.ashx” the line “action.Type = DataActionTypes.[Error]” gave the error that “text” fields could not be compared. I changed the field to NVarCar(256). After doing so, I was able to change existing events (update and delete). So I tried to do the same with the “reoccurring”, but cannot create the table.
Here is the error message I receive:
Msg 1709, Level 16, State 1, Line 2
Cannot use TEXTIMAGE_ON when a table has no text, ntext, image, varchar(max), nvarchar(max), non-FILESTREAM varbinary(max), xml or large CLR type columns.
Then I tried NVarChar(MAX). I was able to create the table.
Is it OK to use NVarChar(256) in the “Events” Table?
Is it OK to use NVarChar(MAX) in the “Recurring” Table?
Hello,
This happen because the classes defined in a Scheduler.dbml does not match the event table. This happens because the classes were created for samples database table, which differs from a table you currently have
Please do not adjust the columns individually, it may take unnecessary time before you find a table configuration that matches the previously created classes. Much more easier and the same effective is to simply drop old classes and recreate them from an actual database msdn.microsoft.com/en-us/library/bb384396.aspx
Please see the second part of my previous reply.
Client-side and the server-side needs a ‘string’ type for these properties. In the database it can be represented as several types: text, nvarchar, varchar. Generally, you can use any