Мне нужно добавить данные пользователя в мою базу данных через форму
Итак, у меня есть форма с таким обработчиком отправки:
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
})
}
Из того, что я понял, функция submit вызывает скрипт (в моем случае save.ashx), который должен обновить мою базу данных!
У меня есть две проблемы:
1-как получить доступ к моим данным (отправлено в форме) Я попытался добавить аргументы в функцию сохранения, как вы увидите ниже, но я не уверен в этом
2-я получаю внутреннюю ошибку сервера при вызове save.ashx
Вот мой сценарий:
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;
}
}
}
спасибо за ваше время