PDA

View Full Version : [CLOSED] Error in Store.Sync.



mis@adphk.com
Dec 01, 2012, 3:24 AM
Now I create a gridPanel and update field. when you want to use store1.sync() which told me need to declare var. But I think I did it. so I want to find out which row I updated in the grid. in Internet I know the function "getModifiedRecords". but I can't use in gridpanel.getStore(), because it didn't show this function below gridpanel.getStore().

any hints in my program? C#

and My program is below second:
the error is below first:


Status Code: 200Status Text: BADRESPONSE: 語法錯誤

{serviceResponse:{success:false,message:"System.Exception: Must declare the scalar variable \"@remark\". ---> System.Data.OleDb.OleDbException: Must declare the scalar variable \"@remark\".\r\n at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method)\r\n at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()\r \n at System.Web.UI.WebControls.SqlDataSourceView.Execut eDbCommand(DbCommand command, DataSourceOperation operation)\r\n at System.Web.UI.WebControls.SqlDataSourceView.Execut eUpdate(IDictionary keys, IDictionary values, IDictionary oldValues)\r\n at System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback)\r\n at Ext.Net.Store.MakeUpdates(IDataSource ds, JArray data) in D:\\component_download\\extnet-Ext.NET.Pro-4a10352\\Ext.Net\\Ext\\Data\\Store.cs:line 890\r\n at Ext.Net.Store.MakeChanges() in D:\\component_download\\extnet-Ext.NET.Pro-4a10352\\Ext.Net\\Ext\\Data\\Store.cs:line 829\r\n at Ext.Net.Store.DoSaving(String action, String jsonData, JToken parameters) in D:\\component_download\\extnet-Ext.NET.Pro-4a10352\\Ext.Net\\Ext\\Data\\Store.cs:line 793\r\n --- End of inner exception stack trace ---\r\n at Ext.Net.Store.DoSaving(String action, String jsonData, JToken parameters) in D:\\component_download\\extnet-Ext.NET.Pro-4a10352\\Ext.Net\\Ext\\Data\\Store.cs:line 806\r\n at Ext.Net.Store.RaiseAjaxPostBackEvent(String eventArgument) in D:\\component_download\\extnet-Ext.NET.Pro-4a10352\\Ext.Net\\Ext\\Data\\Store.cs:line 1131",data:}}


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>己辭職員工例外處理</title>
<style type="text/css">
.x-grid-cell-fullName .x-grid-cell-inner {
font-family : tahoma, verdana;
display : block;
font-weight : normal;
font-style : normal;
color : #385F95;
white-space : normal;
}

.x-grid-rowbody div {
margin : 2px 5px 20px 5px !important;
width : 99%;
color : Gray;
}

.x-grid-row-expanded td.x-grid-cell{
border-bottom-width:0px;
}
.icon-exclamation {
padding-left: 25px !important;
background: url(/icons/exclamation-png/ext.axd) no-repeat 3px 0px !important;
}

.icon-accept {
padding-left: 25px !important;
background: url(/icons/accept-png/ext.axd) no-repeat 3px 0px !important;
}
.my-panel
{
padding-left: 50px;
padding-top: 50px;
padding-bottom: 50px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:resourcemanager ID="ResourceManager1" runat="server"
DirectMethodNamespace="temp" />

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CrystralConnString %>"
SelectCommand="SELECT excludeID, staffID, remark, insertUser, insertDate, updateUser, updateDate FROM tblExcludeStaff where isDel=0"
UpdateCommand = "update tblExcludeStaff set remark = @remark, staffID = @staffID where excludeID = @excludeID"
ProviderName="<%$ ConnectionStrings:CrystralConnString.ProviderName %>" >
<UpdateParameters>
<asp:Parameter Name="remark" Type="String" />
<asp:Parameter Name="staffID" Type="String" />
<asp:Parameter Name="excludeID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>

</div>
<ext:GridPanel ID="GridPanel1" runat="server" Title="Data detail" Height="500px">
<Store>
<ext:Store ID="Store1" runat="server" DataSourceID="SqlDataSource1" OnReadData="Store1_RefershData">
<Model>
<ext:Model runat="server" IDProperty="excludeID">
<Fields>
<ext:ModelField name="excludeID" />
<ext:ModelField name="staffID" Type="String" />
<ext:ModelField name="remark" Type="String" />
<ext:ModelField name="insertUser" />
<ext:ModelField name="insertDate" />
<ext:ModelField name="updateUser" />
<ext:ModelField name="updateDate" />
</Fields>
</ext:Model>
</Model>
<Listeners>
<Exception Handler="Ext.Msg.alert('Operation failed', operation.getError());" />
<Write Handler="Ext.Msg.alert('Write', 'The data successfully saved');" />
</Listeners>
</ext:Store>
</Store>

<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ID="excludeID" runat="server" Text="System ID" width="100" DataIndex="excludeID" Hidden="true" />
<ext:Column ID="staffID" runat="server" Text="Staff ID" width="100" DataIndex="staffID">
<Editor>
<ext:TextField runat="server" />
</Editor>
</ext:Column>
<ext:Column ID="remark" runat="server" Text="remark" width="200" DataIndex="remark">
<Editor>
<ext:TextField runat="server" />
</Editor>
</ext:Column>
<ext:Column ID="insertUser" runat="server" Text="Inupt_staff" width="200" DataIndex="insertUser" Hidden="true" />
<ext:Column ID="insertDate" runat="server" Text="input date" width="200" DataIndex="insertDate" Hidden="true" />
<ext:Column ID="updateUser" runat="server" Text="last update user" width="200" DataIndex="updateUser" Hidden="true" />
<ext:Column ID="updateDate" runat="server" Text="last update date" width="200" DataIndex="updateDate" Hidden="true" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" Mode="Multi" />
</SelectionModel>
<View>
<ext:GridView ID="GridView1" runat="server">
<GetRowClass Handler="return 'x-grid-row-expanded';" />
</ext:GridView>
</View>
<Plugins>
<ext:CellEditing runat="server" />
</Plugins>
</ext:GridPanel>
</Items>

<Buttons>
<ext:Button ID="btnSave" runat="server" Text="Sync" Icon="Disk">
<Listeners>
<Click Handler="#{Store1}.sync();" />
</Listeners>
</ext:Button>
</Buttons>
</ext:Panel>
</Items>
</ext:tabpanel>

</form>
</body>
</html>

Vladimir
Dec 02, 2012, 10:09 AM
'getModifiedRecords' still exists
I don't see in your sample where do you try to use it

Does remark record field have a value in updated record?

mis@adphk.com
Dec 02, 2012, 12:33 PM
Can I ask about how can I get which row I updated in the gridpanel?

I think it is easy to answer. before question I think it is easy to confuse. Sorry.

I am using extnet, version 2.

Vladimir
Dec 02, 2012, 12:51 PM
To retrieve update records you can use the following javascript code


var updatedRecords = App.GridPanel1.store.getUpdatedRecords();

mis@adphk.com
Dec 02, 2012, 11:57 PM
I am still can't find this method.
I am try to call this method in front-end program.



To retrieve update records you can use the following javascript code


var updatedRecords = App.GridPanel1.store.getUpdatedRecords();

Vladimir
Dec 03, 2012, 12:01 AM
Please provide test sample where you try to get updated records

mis@adphk.com
Dec 03, 2012, 12:25 AM
in my question, i find out is updateCommand problem.


"UpdateCommand = "update tblExcludeStaff set remark = @remark, staffID = @staffID where excludeID = @excludeID"

Error message said I need to declare "declare the scalar variable \"@remark\". ---> ", and I try to delete this command line and use auto-sync. the program can save data to db.

so I wanna ask where declare var in this case?

Vladimir
Dec 03, 2012, 12:48 AM
Sorry, I don't understand your requirement clearly, define that var where you need

mis@adphk.com
Dec 03, 2012, 1:00 AM
Sorry, I don't understand your requirement clearly, define that var where you need

Thanks for your reply. I think it isn't code problem. Now I change to a new connection string. The program is working.

UpdateCommand="Update tblExcludeStaff set remark=@remark where excludeID=@excludeID"

so is it any different with my below two connection string?

1. it is work.

<add name="CrystalConnectionStringtest" connectionString="Data Source=192.168.0.5;Initial Catalog=Crystal;User ID=sa;Password=sasa"
providerName="System.Data.SqlClient" />

2. it didn't work. ask me to declare var.

<add name="CrystralConnString" connectionString="Provider=SQLOLEDB;Data Source=192.168.0.5;Persist Security Info=True;Password=sa;User ID=Crystal;Initial Catalog=Crystal"
providerName="System.Data.OleDb" />

Daniil
Dec 03, 2012, 10:33 AM
I see the second connection string is without a password. Maybe this causes the problem.