I need to add user data to my database via a form
So I have a form with a submit handler like this :
xtype: 'fieldset',
title: 'User information',
defaults: {
//width: 230,
labelStyle: 'font-size:10px',
labelWidth: 105
},
defaultType: 'textfield',
layout : 'anchor',
items: [{
fieldLabel: 'Name',
anchor: '98%',
allowBlank: false,
name: 'company'
}, {
fieldLabel: 'Last Name',
anchor: '98%',
name: 'price'
}, {
fieldLabel: 'Email ',
anchor: '98%',
allowBlank: false,
vtype: 'email',
name: 'pctChange'
}
]
},
{ border: false,
buttons: [{
text: 'Update user',
handler: function () {
{
if (this.up('form').getForm().isValid())
{
this.up('form').getForm().submit({url : 'save.cs' }); // this would submit the form to the configured url
//this.up('form').getForm().reset();
Ext.MessageBox.show({
title: 'Success !',
msg: 'Changes saved successfully<br />',
icon: Ext.MessageBox.INFO
})
}
from what i understood,the submit function call a script (in my case save.ashx) that should update my database!
I have two issues :
1-how do I access my data (submited in the form) I tried to add arguments in the save function as you will see below but im not quit sure about this
2-i get an internal server error when the save.ashx is called
Here is my script:
public class save
{
SqlConnection dbConn = new SqlConnection("............");
public void saveUser(string firstname,string lastname,string email)
{
try
{
string str = "insert into UTILISATEUR (firstname, lastname, email ) values ( \""+firstname+"\" , \""+lastname+"\" , \""+email+"\" )";
SqlCommand sqlCommand = new SqlCommand(str);
sqlCommand.Connection = dbConn;
sqlCommand.CommandType = CommandType.Text;
SqlDataAdapter sda = new SqlDataAdapter(sqlCommand);
dbConn.Open();
if (sqlCommand.Connection.State == ConnectionState.Open)
{
sqlCommand.ExecuteNonQuery();
dbConn.Close();
}
}
catch (Exception ex)
{
throw ex;
}
}
}
thanks for ur time