using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
String conex;
String sql;
SqlConnection cn;
SqlCommand cmd;
conex = "Data Source=(local);";
conex += "Initial Catalog=test;";
conex += "user=sa;";
conex += "pwd=placabase;";
sql = "INSERT INTO usuarios VALUES('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "')";
cn
= new SqlConnection
(conex
); try
{
cn.Open();
cmd
= new SqlCommand
(sql, cn
); cmd.ExecuteNonQuery();
Label4.Text = "Guardado Correctamente";
}
catch (Exception ex)
{
Label4.Text = "Ocurrio un error: " + ex.Message;
}
finally
{
cn.Close();
}
}
}