No logro insertar un registro en us sistema que estoy haciendo para la facultad. Necesito ingresar unos valores en un registro y no logro hacerlo.
Soy muy nuevo con c# y realmente estoy en pañales, por lo cual agradeceré mucho su ayuda.
En primer lugar cree un formulario aspx,con algunos textBox y un boton y arrastré un accessDataSource.
Luego este es el codigo:
Código PHP:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AccessDataSource3.InsertCommand = "";
AccessDataSource3.SelectCommand = "";
}
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
}
protected void AccessDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
string sql = "insert into presupuesto (producto,fechaCompra,fechaFinalizacion,lugarCompra,enGarantia) values ('" + txtArticulo.Text + "',#" + TextFechacompra.Text + "#,#" + TextFechaFinalizacion.Text + "#,'" + TextLugarCompra.Text + "','" + CheckGarantia.Text + "')";
AccessDataSource3.InsertCommand = sql;
}
}
El sql que genera es el siguiente:
insert into presupuesto (producto,fechaCompra,fechaFinalizacion,lugarCompr a,enGarantia) values ('yghjghj',#1/12/2000#,#1/12/2000#,'sfs','')
No arroja ningun error, pero no graba el registro en la tabla.
Que me está faltando?
Desde ya muchicimas gracias