iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
i have my application server installed in 192.168.1.1 and my database server (ms sql) in 192.168.1.2.
From my application, how can ISDataSource connect to database in my database server?
Thanks!
I hit this error when run the provided code:
Unable to cast object of type 'System.Data.SqlClient.SqlConnection' to type 'System.Data.OleDb.OleDbConnection'
Pls advise
The code I converted was from the earlier snippet that I send for you in C#. Since in your code you are using SqlConnection and not OleDB connection you will need to use SqlConnection. Here is the snippet:
Dim conn As SqlConnection = e.ObjectInstance.GetType().GetProperty("Connection", BindingFlags.NonPublic + BindingFlags.Instance).GetValue(e.ObjectInstance, Nothing)
WebScheduler will override any onload client side event handler in order to facilitate WebScheduler internal process. You could try using the WebScheduler OnInitialize client side event handler for similar life cycle with the OnLoad event handler. In your case, the OnInitialize event handler would be:
function wsSchedule_OnInitialize(controlId) { var wsSchedule = ISGetObject(controlId); setTimeout(function() { RefreshScheduler() }, 50); return true;}
The setTimeout is required to achieve the scenario you wanted.
You are using WebButton to post back the page and by default the PostBackMode of the WebButton is FlyPostBack. In order to refresh the scheduler during button click please use the InvokeScript function in the WebButton ClientAction property. Here is the snippet:
Private Sub wbInsert_Clicked(ByVal sender As Object, ByVal e As ISNet.WebUI.WebDesktop.WebButtonClickedEventArgs) Handles wbInsert.Clicked Dim strSQL As String Dim dsStaffInfo As DataSet Dim dsRecurrenceInfo As DataSet strSQL = "INSERT INTO ttResources (StaffCode, StaffName, ResourceColor) VALUES ('SC02', 'Staff 02', '#00FF')" conn.ExecuteCommand(strSQL) strSQL = "SELECT ID, StaffCode, StaffName FROM ttResources" dsStaffInfo = conn.ExecuteSelect(strSQL) strSQL = "INSERT INTO ttEvents (StaffID, ActivityCode, ActivityName, RoomID, Location, StartTime, EndTime, ScheduleID, Description) " _ & "VALUES ('" + dsStaffInfo.Tables(0).Rows(0).Item("ID").ToString + "', 'INWKA', 'INWKA', 1, 'BC01-F01-LR02', '2010-02-22 08:00:00.000', '2010-02-22 09:00:00.000', 1, 'Resources - Staff 02 (Staff 02) Activity - (INWKA) Venue - BC01-F01-LR02')" conn.ExecuteCommand(strSQL) strSQL = "INSERT INTO ttRecurrenceInfo (StartDate, EndDate, TotalRecurrence, WeekDay, ScheduleID, Mode, RangeMode) " _ & "VALUES('2010-01-04 00:00:00.000', '2010-03-31 00:00:00.000', '10', '1', '1', '2', '0')" conn.ExecuteCommand(strSQL) strSQL = "SELECT ID FROM ttResources" dsRecurrenceInfo = conn.ExecuteSelect(strSQL) strSQL = "INSERT INTO ttRecurringEvents (RecurrenceID, StaffID, ActivityCode, ActivityName, RoomID, Location, StartTime, EndTime, ScheduleID, " _ & "Description) " _ & "VALUES('" + dsRecurrenceInfo.Tables(0).Rows(0).Item("ID").ToString + "', '" + dsStaffInfo.Tables(0).Rows(0).Item("ID").ToString + "', 'ICSALab1', 'ICSALab1', 2, 'BC01-F01-CL02', '2010-01-04 08:00:00.000', '2010-01-04 09:00:00.000', 1, 'Resources - Staff 02 (Staff 02) Activity - Introduction to Computer Science (L) (ICSALab1) Venue - BC01-F01-CL02') " conn.ExecuteCommand(strSQL) wbInsert.ClientAction.InvokeScript("RefreshScheduler()") End Sub
In the ISDataSource documentation, section titled "Walkthrough Topics" we have shown how to bind data to ISDS. You will need a dataset in your app_code folder in your project. This dataset will use a connection string that points to your database server.
If make use of dataset, i'll need to set the connection to database during design time.
For my case, i need to connect to different database based on user login.
How can i make my WebScheduler connect to different database dynamically during run time?
You could modify the connection string programatically during ISDataSource object created server side event using reflection. However the DB you changed to must have the same structure with the one you assign in the design mode. Here is the snippet of object created server side event handler:
protected void ISDataSource1_ObjectCreated(object sender, ISNet.WebUI.DataSource.ISDataSourceEventArgs e){ OleDbConnection conn = (OleDbConnection)e.ObjectInstance.GetType().GetProperty("Connection", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(e.ObjectInstance, null); conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\WebScheduler_Software_2.mdb;Persist Security Info=True";}
The original data source of the ISDS in the snippet is WebScheduler_Software.mdb
Before that, i need to bind my WebScheduler to ISDataSource rite? Below is my code for WebScheduler and ISDataSource in my aspx file:
While in dsSchedule_Extended.vb, i have code as below:
Imports Microsoft.VisualBasic
Imports System
Namespace dsScheduleTableAdapters
I compiled without error, but when i run it, i'll hit error as in attachment.
What do i miss out?
My test show that the WebScheduler will need at least Events, Categories, and Resources table binding for the WebScheduler to works without any issue. An article regarding this issue has been detailed in the WebScheduler documentation, the article is titled "Walkthrough: Binding Access database to WebScheduler using ISDataSource"
Hi,
I have some issue with ISDataSource.
1) I create a new WebApplication project.
2) I create App_Code folder.
3) I create new dataset inside App_Code folder.
4) I drag & drop ISDataSource into aspx file.
5) I configure ISDataSource through wizard, but i can't c the dataset in the list.
The problem doesn't exist when i create WebSite project.
Pls advise.
In my simple test project, using WebApplication or WebSite project will not result in empty schema list in the ISDataSource wizard. The empty schema list might occur if you already reference a large number of dll in your project or if there is some error in the project.
Please try create a simple WebApplication project with dataset that points to nortwind.mdb data and ISDataSource, if the issue does occur, please attached the simple project so we could analyze the issue further.
Attached is the simple WebApplication project which the dataset is not listed in the ISDataSource configure data source wizard.
When i create the same thing but using WebSite, then the dataset do appear.
This issue occurs because the behavior in VB WebApplication project. In my research, VB WebApplication will not be able to read from the App_Code folder if the bin folder already exist. You could check the behavior for ObjectDataSource control which will have the same behavior as ISDataSource in VB WebApplication.
The workaround is to be creat the dataset in the bin folder for VB WebApplication. This will allow the wizard to show your dataset in the schema dropdown list.
I managed to bind my WebScheduler to ISDataSource already. But there's a problem. The WebScheduler only show event stored in Events table but not RecurringEvents table. Below is the code where i bind WebScheduler to ISDataSource:
Any idea?
Based on my analysis of the snippet, I suspect that you are missing some field and table in the DataBinding propterty. Please compare it to one of the WebScheduler provided sample, such as Agenda_Navigation.aspx
The ISDS markup already contains a Category table, however you are not binding this table to the WebScheduler. The WebScheduler alsio already refrence the Categories table in the CategoriesDataMember.
In the RecurringEventsBinding property, some attribute is not assigned, such as EventIDField and ReminderDismiss.
I also see that the RecurrenceInfo table and RecurringEvents table contains a ScheduleID field in the ISDs which is not bound in the WebScheduler databinding.
I tested bind all the required field, but it still show event in events table only.
Attached is the sample i did.
There's "script" folder and there's script to create tables and insert data.
Pls help! thanks!
After analysing the attached project, the issue seems to be caused by invalid value in Mode and RangeMode field on RecurrenceInfo table. The Mode field and AllDayEvent in the Recurring Event table also have invalid value.
These field, Mode, RangeMode, and AllDayEvent, must not have null value. Did you insert the data manually into the database? Please compare it with the data inserted using the EditingForm in the provided WebScheduler sample in order to understand the value required in the fields.
I inserted 2 for RecurrenceInfo.Mode and 0 for RecurrenceInfo.RangeMode then it shows correctly. But i would like to know what does it meant when RecurrenceInfo.Mode = 2 and RecurrenceInfo.RangeMode = 0?
Then regarding your previous post you said we could modify the connection string programatically during ISDataSource object created server side event using reflection. From your snippet, you only change the .mdb? How if i would like to change the connection string as below:
Data Source=DEVDB01\SQLEXPRESS;Initial Catalog=Optimizer_01;Persist Security Info=True;User ID=saUser;Password=saPassword
to
Data Source=DEVDB01\SQLEXPRESS;Initial Catalog=Optimizer_02;Persist Security Info=True;User ID=saUser;Password=saPassword
You could read more about WebSchedulerRecurrenceMode and WebSchedulerRecurrenceRangeMode in the WebScheduler documentation under the article titled "WebSchedulerRecurrenceMode Enumeration" and "WebSchedulerRecurrenceRangeMode Enumeration". You could also try adding recurring event in our sample and check the new entry in the database in order to determine the value.
Programmatically changing the data source connection will also work with such connection, as long as the database has the same table structure and query defined in the database operation of the WebScheduler.
I tried put the code in ISDataSource object created server side event, but the event is not fired when run. You may tried out my previous sample.
For the code u gave previously is in csharp rite, how about vb code?
In my test, in order to attach the ObjectCreated event handler you will need to set the event handler in the design mode. Here is the snippet:
<isdatasource:isdatasource runat="server" ID="ISDSSchedule" SchemaName="WebScheduler.dsSchedule" onobjectcreated="ISDSSchedule_ObjectCreated">
As you requested, here is the event handler / reflection code in VB:
Protected Sub ISDSSchedule_ObjectCreated(ByVal sender As Object, ByVal e As ISNet.WebUI.DataSource.ISDataSourceEventArgs) Dim conn As OleDbConnection = e.ObjectInstance.GetType().GetProperty("Connection", BindingFlags.NonPublic + BindingFlags.Instance).GetValue(e.ObjectInstance, Nothing) conn.ConnectionString = 'New connection stringEnd Sub
ok, it works now!
Hi Glenn,
Now my WebScheduler can connect to different database dynamically during run time, but there's another issue.
Initially there's no record in Events and RecurringEvents table. So when my system load the page with WebScheduler, the WebScheduler will show calendar only as there's no event yet.
On the same page, i have button to insert record into Events and RecurringEvents table. When i click the button and insert record and the page is post back, the content in WebScheduler is not updated accordingly, the WebScheduler still show calendar only without any event. I need to refresh the page manually in order for the WebScheduler to "refresh".
How can i make the WebScheduler to "refresh" during post back after the button is clicked?
Since the original question of this thread has been solved, next time please create a new thread if you have a new question.
WebScheduler have a method to refresh the data programatically using the RefreshAll client side function. Here is the snippet:
function RefreshScheduler() { var sched = ISGetObject("WebScheduler1"); sched.RefreshAll();}
The code should be placed in client/server site?
Can u provide a sample?
How should i called the function?
I have 2 functions defined as below, wtvActivity_OnNodeCheckedChanged is called without problem but not RefreshScheduler:
a[i] = checkedNodes[i].Name;
{ hidden1.value = a[i]; }
}
sched.RefreshAll();
Below is the code how i called the function:
<ISWebScheduler:WebScheduler ID="wsSchedule" runat="server" CategoriesDataMember="ttCategories" DataSourceID="ISDSSchedule"
I tested with all other client side events OnDataBinding / OnDataBound / OnInit / OnInsert / OnLoad / OnPreInitialize / OnPreRender / OnUpdate.
and i get error:
BC30456: 'RefreshScheduler' is not a member of 'ASP.schstaffplanner_aspx'.
In the snippet you provided, you are trying to use a client side function to handle a server side event. As I mentioned before, WebScheduler RefreshAll is a client side function so it should be invoked in the client side event such as the events defined under ClientSideEvents property.
In the previous post you mention:
If the issue occurs after full postback, you could try to invoke the RefreshScheduler function during HTML body OnLoad client side event handler.
If the suggestion does not solve the issue please send us a sample of the page so we could help you determine the issue.
Attached is the sample to reproduce the issue. Inside the folder, there's CreateTable.sql to create the needed tables.
There are 2 issues here:
1) The function is not called during onLoad when there's WebScheduler in the aspx. If the WebScheduler is removed, then the function is called without problem during onLoad.
2) I'm not able to refresh the WebSchduler after page post back.
ok that solves the problem.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname