Está en la página 1de 3

Gilber Gomez Familia

2019-2854
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace TrabajandoConMdi
{
public partial class Nuevo : Form
{
public Nuevo()
{
InitializeComponent();
}

private void btnInsertar_Click(object sender, EventArgs e)


{
SqlConnection conexion = new SqlConnection("server=GILBER-PC ;
database=base1 ; integrated security = true");
conexion.Open();
string id = txtID.Text;
string usuario = txtUsuario.Text;
string clave = txtClave.Text;
string nombre = txtNombre.Text;
string apellido = txtApellido.Text;
string correo = txtCorreo.Text;

string cadena = "insert into cliente(id, usuario, clave, nombre,


apellido, correo) values ('" + id + "'," + usuario + "," + clave + "," + nombre +
"," + apellido + "," + correo + ")";

SqlCommand comando = new SqlCommand(cadena, conexion);


comando.ExecuteNonQuery();
MessageBox.Show("Los datos se guardaron correctamente");
txtID.Text = "";
txtUsuario.Text = "";
txtClave.Text = "";
txtNombre.Text = "";
txtApellido.Text = "";
txtCorreo.Text = "";

conexion.Close();
}
}
}
Gilber Gomez Familia
2019-2854
Gilber Gomez Familia
2019-2854

También podría gustarte