We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

sql update won't working

Hi, i've adapted below sample with my sql database+table, it's working but permanently sql update,sql table not :/
why?
what is missing?

https://asp.syncfusion.com/demos/web/grid/sqlbinding.aspx 

Thanks.


3 Replies

SO Soykan OZCELIK November 6, 2022 05:46 PM UTC

and here is my aspx page codes


<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BonbiliWebApplication._Default" %>


<%@ Register Assembly="Syncfusion.EJ.Web, Version=20.3460.0.47, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" Namespace="Syncfusion.JavaScript.Web" TagPrefix="ej" %>


<%@ Register Assembly="Syncfusion.EJ, Version=20.3460.0.47, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" Namespace="Syncfusion.JavaScript.Models" TagPrefix="ej" %>



<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">

    <script src="../Scripts/jquery.validate.min.js" type="text/javascript"></script>

    <div>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server">

            <ContentTemplate>

                <div class="row">

                    <div>

                        <h2>SyncFusion Grid Test</h2>

                        <div id="grd">

                            <ej:Grid runat='server' ID="grdTest" IsResponsive="true"

                                AllowSearching="True"

                                AllowGrouping="False"

                                AllowSorting="True"

                                AllowPaging="True"

                                AllowResizeToFit="True"

                                AllowFiltering="False"

                                 OnServerEditRow="EditEvents_ServerEditRow"

                                OnServerAddRow="EditEvents_ServerAddRow"

                                OnServerDeleteRow="EditEvents_ServerDeleteRow">


                                <ClientSideEvents ActionComplete="complete" EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit"

                                    RecordDoubleClick="doubleClick" />

                                <Columns>

                                    <ej:Column Field="PRMKEY" IsPrimaryKey="true" Visible="false">

                                        <ValidationRule>

                                            <ej:KeyValue Key="required" Value="true" />

                                            <ej:KeyValue Key="string" Value="true" />

                                        </ValidationRule>

                                    </ej:Column>

                                    <ej:Column Field="ISLEMTARIH" HeaderText="TARIH">

                                    </ej:Column>

                                    <ej:Column Field="ISLEMSAAT" HeaderText="SAAT">

                                    </ej:Column>

                                    <ej:Column Field="CARINO">

                                    </ej:Column>

                                    <ej:Column Field="FIRMA">

                                    </ej:Column>

                                    <ej:Column Field="MODUL">

                                    </ej:Column>

                                    <ej:Column Field="ERTMAXGUN">

                                    </ej:Column>

                                    <ej:Column Field="ERTGUNSAY">

                                    </ej:Column>

                                    <ej:Column Field="INTISLEM">

                                    </ej:Column>

                                    <ej:Column Field="USERIP">

                                    </ej:Column>

                                    <ej:Column Field="USERBROWSE">

                                    </ej:Column>

                                    <ej:Column Field="USERREGION">

                                    </ej:Column>

                                    <ej:Column Field="DEVICEID">

                                    </ej:Column>

                                    <ej:Column Field="KAPALIGUN">

                                    </ej:Column>

                                    <ej:Column Field="TESLIMADRS">

                                    </ej:Column>

                                    <ej:Column Field="PLATFORM">

                                    </ej:Column>

                                    <ej:Column Field="BROWSEROS">

                                    </ej:Column>

                                    <ej:Column Field="DVCMODEL">

                                    </ej:Column>

                                </Columns>

                                <EditSettings EditMode="Normal" ShowDeleteConfirmDialog="true" AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings>

                                <ToolbarSettings ShowToolbar="True" ToolbarItems="search,add,edit,delete,update,cancel,excelExport,wordExport,pdfExport"></ToolbarSettings>

                            </ej:Grid>

                        </div>

                    </div>

                </div>

            </ContentTemplate>

        </asp:UpdatePanel>

    </div>

    <asp:SqlDataSource ID="SqlDsIntlogs" runat="server"

        ConnectionString=""

        SelectCommand=""></asp:SqlDataSource>


       <script type="text/javascript">

           function endAdd(args) {

               $('#<%= grdTest.ClientID %>').ejWaitingPopup("show");

           }

           function endDelete(args) {

               $('#<%= grdTest.ClientID %>').ejWaitingPopup("show");

       }

       function endEdit(args) {

           $('#<%= grdTest.ClientID %>').ejWaitingPopup("show");

       }

       function complete(args) {

           if (args.requestType == "refresh") {

               $('#<%= grdTest.ClientID %>').ejWaitingPopup("hide");

               }

           }

       </script>


</asp:Content>







SO Soykan OZCELIK November 6, 2022 05:49 PM UTC

and here is .cs codes

using System;

using System.Collections.Generic;

using System.Configuration;

using System.Data.SqlClient;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using Syncfusion.JavaScript.Web;


namespace BonbiliWebApplication

{

public partial class _Default : Page

{

public string psConnStr = @"Data Source=xxx.xxx.xxx.xxx;Initial Catalog=demodb;User ID=demodb;Password=demopwd";

DataTable dt = new DataTable("intlogs");

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{


var commandSqlText = @"select format(i.ISLEMTARIH,'dd.MM.yyyy') as ISLEMTARIH,format(i.ISLEMTARIH,'HH:mm:ss') as ISLEMSAAT,

i.CARINO,m.FIRMA,i.MODUL,i.ERTMAXGUN,i.ERTGUNSAY,i.INTISLEM,

i.USERIP,i.USERBROWSE,i.USERREGION,i.DEVICEID,

i.KAPALIGUN,i.TESLIMADRS,

i.PLATFORM,i.BROWSEROS,i.DVCMODEL,i.PRMKEY

from intlogs i WITH(NOLOCK)

inner join musbil m WITH(NOLOCK) on m.CARINO=i.CARINO

where i.ISLEMTARIH between convert(date,getdate()-1) and convert(date,getdate()+1)

--and (MODUL='ErteleUpdt' or MODUL='ErteleIpt')

order by i.ISLEMTARIH desc";


SqlConnection myConnection = new SqlConnection(psConnStr); //new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnectionString"].ToString());

dt = new DataTable("intlogs");

SqlCommand cmd = new SqlCommand();

cmd.Connection = myConnection;

cmd.CommandText = commandSqlText; //"select * from intlogs";

cmd.CommandType = CommandType.Text;

SqlDataAdapter da = new SqlDataAdapter();

da.SelectCommand = cmd;

if (myConnection.State == ConnectionState.Closed)

{

myConnection.Open();

}

da.Fill(dt);

Session["SqlDataSource"] = dt;

dataBind();

}

}

protected void dataBind()

{


SqlDsIntlogs.ConnectionString = psConnStr;

grdTest.DataSource = (DataTable)Session["SqlDataSource"];

grdTest.DataBind();


}


protected void EditEvents_ServerEditRow(object sender, GridEventArgs e)

{

EditAction(e.EventType, e.Arguments["data"]);


}


protected void EditEvents_ServerAddRow(object sender, GridEventArgs e)

{

EditAction(e.EventType, e.Arguments["data"]);

}


protected void EditEvents_ServerDeleteRow(object sender, GridEventArgs e)

{

EditAction(e.EventType, e.Arguments["data"]);

}


protected void EditAction(string eventType, object record)

{

SqlConnection myConnection = new SqlConnection(psConnStr); //new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnectionString"].ToString());

dt = Session["SqlDataSource"] as DataTable;

Dictionary KeyVal = record as Dictionary;

if (eventType == "endEdit")

{

//var Order = KeyVal.Values.ToArray();

var pKey = KeyVal.Values.ToArray();

foreach (DataRow dr in dt.Rows)

{

if (dr["PRMKEY"].ToString() == Convert.ToString(pKey[0])) //Convert.ToInt32(Order[0])

{

dr["FIRMA"] = pKey[4];

//dr["Freight"] = Order[2];

//dr["ShipCity"] = Order[3];

//dr["ShipCountry"] = Order[4];

dr.AcceptChanges();

}


}

}


else if (eventType == "endAdd")

{

//var Order = KeyVal.Values.ToArray();

var pKey = KeyVal.Values.ToArray();

DataRow dr = dt.NewRow();

dr["FIRMA"] = pKey[4];

//dr["EmployeeID"] = Order[1];

//dr["Freight"] = Order[2];

//dr["ShipCity"] = Order[3];

//dr["ShipCountry"] = Order[4];

dt.Rows.Add(dr);

}

else if (eventType == "endDelete")

{

//var Order = KeyVal.Values.ToArray();

var pKey = KeyVal.Values.ToArray();

if (Session["SqlDataSource"] != null)

{

DataRow[] rows = dt.Select("PRMKEY = " + pKey[0]);


foreach (DataRow row in rows)

dt.Rows.Remove(row);


}

}

Session["SqlDataSource"] = dt;

dataBind();

}

}

}



PS Pon Selva Jeganathan Syncfusion Team November 8, 2022 04:07 AM UTC


Hi Soykan OZCELIK,


Query:  i've adapted below sample with my sql database+table, it's working but permanently sql update,sql table not :/ why?.. what is missing?


We checked your query by preparing a sample using mentioned package version(20.3.0.47) but we were unable to replicate the issue at our end.


Please refer to the below sample,

https://www.syncfusion.com/downloads/support/directtrac/general/ze/SyncfusionASPNETApplication3-1872736495


If you still facing issue after trying the above method, please provide the following information


  1. Replication steps of the issue
  2. Video demo of the issue and share the stacktrace details (if face any)
  3. Try to replicate the issue in our shared sample or share the issue reproducible sample.


The requested information will be helpful to proceed further


Regards,
Pon selva



Loader.
Live Chat Icon For mobile
Up arrow icon