---
title: "How to Insert data In database using sencha touch Extjs."  
description: "How to Insert data In database using sencha touch Extjs."  
author: "Anonymous User"  
published: 2016-04-15  
updated: 2016-04-15  
canonical: https://www.mindstick.com/forum/34103/how-to-insert-data-in-database-using-sencha-touch-extjs  
category: "javascript"  
tags: ["jquery", "javascript"]  
reading_time: 3 minutes  

---

# How to Insert data In database using sencha touch Extjs.

We want to [Insert data In database](https://www.mindstick.com/forum/33723/insert-data-in-database-using-windows-application-c-sharp) using [sencha touch](https://www.mindstick.com/interview/23004/define-class-system-of-sencha-touch) Extjs. How to do this Please Help Me.

## Replies

### Reply by Anonymous User

```
TableCREATE TABLE Users(  [UserId] INT PRIMARY KEY IDENTITY(1,1),     [UserFname] VARCHAR(100),   [UserLname] VARCHAR(100),  [UserPhone] VARCHAR(20),  [UserEmail] VARCHAR(100),  [UserAddress] VARCHAR(500),  [UserPin] VARCHAR(12))
```

```
Index  @model Sencha.Models.User @{    ViewBag.Title = "Index";} <h2 style="width: 500px; font-size: 30px; color: #157FCC;">Sencha Touch</h2><script src="~/ext-6.0.2/build/ext-all.js"></script><link href="~/ext-6.0.2/build/classic/theme-neptune/resources/theme-neptune-all.css" rel="stylesheet" /><script>    Ext.create('Ext.form.Panel', {        title: 'User Account',        bodyPadding: 5,         bodyStyle: 'margin:5px auto 0 auto',        width: 500,               url: 'Home/Index',        layout: 'anchor',        defaults: {             anchor: '100%'         },             defaultType: 'textfield',        items: [{             fieldLabel: 'First Name',            name: 'UserFname',            allowBlank: false         }, {             fieldLabel: 'Last Name',            name: 'UserLname',            allowBlank: false         }, {             fieldLabel: 'Email Id',            name: 'UserEmail',            allowBlank: false         }, {             fieldLabel: 'Phone Number',            name: 'UserPhone',            allowBlank: true         }, {             fieldLabel: 'Address',            name: 'UserAddress',            allowBlank: true         },        , {             fieldLabel: 'Pin Code',            name: 'UserPin',            allowBlank: true         }        ],              buttons: [{             text: 'Reset',            handler: function () {                this.up('form').getForm().reset();            }        }, {             text: 'Submit',            formBind: true, //only enabled once the form is valid            disabled: true,            handler: function () {                var form = this.up('form').getForm();                if (form.isValid()) {                    form.submit({                         success: function (form, action) {                            form.reset();                             Ext.Msg.alert('Success', action.result.msg);                        },                         failure: function (form, action) {                                                  Ext.Msg.alert('Failed', action.result.msg);                        }                    });                }            }        }],        renderTo: Ext.getBody()    }); </script> 
```

```
Controllerusing Sencha.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;
using System.Data.SqlClient;
namespace Sencha.Controllers {     public class HomeController : Controller{         SqlConnection cn = new SqlConnection("Your Connection String");
        SqlCommand cmd = new SqlCommand();
        string Sqlstr = "";
        // GET: /Home/
        [HttpGet]
        public ActionResult Index()        {             return View();        }         [HttpPost]        public ActionResult Index(User obj)        {             bool success=false;            string msg = "Fail";            Sqlstr = "insert into users([UserFname],[UserLname],[UserPhone],[UserEmail],[UserAddress],[UserPin] ) values('"+obj.UserFname+"','"+obj.UserLname+"','"+obj.UserPhone+"','"+obj.UserEmail+"','"+obj.UserAddress+"','"+obj.UserPin+"')";             cn.Open();            cmd.CommandText = Sqlstr;            cmd.Connection = cn;           int count= cmd.ExecuteNonQuery();            cn.Close();             if (count > 0)            {                 success = true;                msg = "success";            }             return Json(new { success = success, msg = msg }, JsonRequestBehavior.AllowGet);         }    }}  
```

```
Users.cs using System;using System.Collections.Generic;using System.ComponentModel;using System.ComponentModel.DataAnnotations;using System.Linq;using System.Web;
namespace Sencha.Models{     public class User     {         [DisplayName("First Name")]        [Required]        public string UserFname { get; set; }        [DisplayName("Last Name")]        [Required]        public string UserLname { get; set; }        [DisplayName("Phone Number")]        [Required]        public string UserPhone { get; set; }        [DisplayName("Email Address")]        [Required]        public string UserEmail { get; set; }        [DisplayName("Address")]        [Required]        public string UserAddress { get; set; }        [DisplayName("Pin Code")]        [Required]        public string UserPin { get; set; }    }}  
```

```

```

```

```

```
Result  SELECT * FROM Users 
```

I hope this example helps you.


---

Original Source: https://www.mindstick.com/forum/34103/how-to-insert-data-in-database-using-sencha-touch-extjs

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
