Insertarbotones en c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ClaseMiercoles29mayo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void butBuscar_Click(object sender, EventArgs e)
{
string conexion = @"Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:basevendedores.accdb";
//Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:UsersCoodinacionDocumentsDatabase2.accdb;Persist Security Info=False";
string ssql = "Select * From Tabla1 where Idv =" + Int32.Parse(textId.Text);
OleDbDataAdapter da = new OleDbDataAdapter(ssql, conexion);
OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
DataTable dt = new DataTable();
da.Fill(dt);
int fila1 = 0;
if (dt.Rows.Count > 0)
{
DataRow dr = dt.Rows[fila1];
textNombre.Text = dr["vNombre"].ToString();
OleDbDataAdapter da2 = new OleDbDataAdapter("select * from Tabla1", conexion);
OleDbCommandBuilder cb2 = new OleDbCommandBuilder(da2);
//DataTable dt2 = new DataTable();
DataSet dsDatos = new DataSet();
da2.Fill(dsDatos, "Vendedores");
this.dataGridView1.DataMember = "Vendedores";
this.dataGridView1.DataSource = dsDatos;
}
else
{
textNombre.Text = "";
MessageBox.Show("No hay datos");
}
}
private void buttInsertar_Click(object sender, EventArgs e)
{
string conexion = @"Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:basevendedores.accdb";
string vSql = "Insert into Tabla1 (idv, VNombre) values ( " + Int32.Parse(textId.Text) + " ,'" +
textNombre.Text + "')";
OleDbConnection miConeccion = new OleDbConnection(conexion);
OleDbCommand miComando = new OleDbCommand(vSql);
miComando.Connection = miConeccion;
miConeccion.Open();
miComando.ExecuteNonQuery();
miComando.Connection.Close();
MessageBox.Show("Alumo Agregado exitosamente");
}
private void buttActualizar_Click(object sender, EventArgs e)
{
string conexion = @"Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:basevendedores.accdb";
string vSql = "Update Tabla1 set VNOmbre = '" + textNombre.Text + "'" + " where Idv =" +
Int32.Parse(textId.Text);
OleDbConnection miConeccion = new OleDbConnection(conexion);
OleDbCommand miComando = new OleDbCommand(vSql);
miComando.Connection = miConeccion;
miConeccion.Open();
miComando.ExecuteNonQuery();
miComando.Connection.Close();
MessageBox.Show("Alumo Actualizado exitosamente");
}
private void buttEliminar_Click(object sender, EventArgs e)
{
string conexion = @"Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:basevendedores.accdb";
string vSql = "Delete from Tabla1 where Idv =" + Int32.Parse(textId.Text);
OleDbConnection miConeccion = new OleDbConnection(conexion);
OleDbCommand miComando = new OleDbCommand(vSql);
miComando.Connection = miConeccion;
miConeccion.Open();
miComando.ExecuteNonQuery();
miComando.Connection.Close();
MessageBox.Show("Alumo Eliminado exitosamente");
}
}
}

More Related Content

PDF
Fetch data from form
PDF
2nd-Order-SQLi-Josh
PDF
MegaScriptSample - Released x-x-15
PPTX
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PDF
PDF
PDF
#win8acad : Building Metro Style Apps with XAML for .NET Developers
PPT
Data management with ado
Fetch data from form
2nd-Order-SQLi-Josh
MegaScriptSample - Released x-x-15
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
#win8acad : Building Metro Style Apps with XAML for .NET Developers
Data management with ado

What's hot (20)

PPT
Wicket Security Presentation
PPTX
20131004 - Sq lite sample by Jax
PDF
Nestjs MasterClass Slides
PDF
NestJS
PDF
Testing with Containers
TXT
Examplecode
PPTX
SQLite with UWP
PPTX
Dot net technology
PPTX
Html web sql database
PDF
End to end todo list app with NestJs - Angular - Redux & Redux Saga
PPTX
Retrofit Web Forms with MVC & T4
PPTX
Introduction to ASP.Net Viewstate
PDF
PPTX
SPFx: Working with SharePoint Content
PPTX
SPFx working with SharePoint data
PDF
Cocoa heads testing and viewcontrollers
PDF
Contact Book Version 1.0
PDF
Backendless apps
PDF
iOS testing
DOCX
ObjectCreatorUserGuide
Wicket Security Presentation
20131004 - Sq lite sample by Jax
Nestjs MasterClass Slides
NestJS
Testing with Containers
Examplecode
SQLite with UWP
Dot net technology
Html web sql database
End to end todo list app with NestJs - Angular - Redux & Redux Saga
Retrofit Web Forms with MVC & T4
Introduction to ASP.Net Viewstate
SPFx: Working with SharePoint Content
SPFx working with SharePoint data
Cocoa heads testing and viewcontrollers
Contact Book Version 1.0
Backendless apps
iOS testing
ObjectCreatorUserGuide
Ad

Viewers also liked (7)

DOC
Melford Written Analysis
PPTX
Project management using six sigma
PPTX
Managerial Accounting Case
DOC
Executive Summary Case 4 Melford
PPTX
Aircraft maintenance package methods
PPTX
Aircraft maintenance program
Melford Written Analysis
Project management using six sigma
Managerial Accounting Case
Executive Summary Case 4 Melford
Aircraft maintenance package methods
Aircraft maintenance program
Ad

Similar to Insertarbotones en c (9)

PDF
Ejercicio sql server vs visual .net
PDF
Bt0082 visual basic2
DOCX
Public class form1
DOCX
Public class form1
PPT
Database Connection
PDF
Form1.vb
DOCX
Practica porfe agustin eliminar y grabar
PDF
(CRUD) How To Connect To Microsoft Access Database Insert Update Delete Clear...
PPTX
76.pptx ajx ppt file for univercity of granted
Ejercicio sql server vs visual .net
Bt0082 visual basic2
Public class form1
Public class form1
Database Connection
Form1.vb
Practica porfe agustin eliminar y grabar
(CRUD) How To Connect To Microsoft Access Database Insert Update Delete Clear...
76.pptx ajx ppt file for univercity of granted

Recently uploaded (20)

DOCX
Center Enamel A Strategic Partner for the Modernization of Georgia's Chemical...
PDF
TyAnn Osborn: A Visionary Leader Shaping Corporate Workforce Dynamics
PPTX
TRAINNING, DEVELOPMENT AND APPRAISAL.pptx
PPTX
Slide gioi thieu VietinBank Quy 2 - 2025
PDF
Chapter 2 - AI chatbots and prompt engineering.pdf
PDF
Booking.com The Global AI Sentiment Report 2025
PDF
Daniels 2024 Inclusive, Sustainable Development
PDF
Satish NS: Fostering Innovation and Sustainability: Haier India’s Customer-Ce...
PDF
ICv2 White Paper - Gen Con Trade Day 2025
PDF
Robin Fischer: A Visionary Leader Making a Difference in Healthcare, One Day ...
PDF
Charisse Litchman: A Maverick Making Neurological Care More Accessible
PPTX
operations management : demand supply ch
PDF
Solaris Resources Presentation - Corporate August 2025.pdf
DOCX
FINALS-BSHhchcuvivicucucucucM-Centro.docx
PPTX
BUSINESS CYCLE_INFLATION AND UNEMPLOYMENT.pptx
PPTX
interschool scomp.pptxzdkjhdjvdjvdjdhjhieij
PPTX
Astra-Investor- business Presentation (1).pptx
PDF
PMB 401-Identification-of-Potential-Biotechnological-Products.pdf
PDF
THE COMPLETE GUIDE TO BUILDING PASSIVE INCOME ONLINE
PPT
Lecture 3344;;,,(,(((((((((((((((((((((((
Center Enamel A Strategic Partner for the Modernization of Georgia's Chemical...
TyAnn Osborn: A Visionary Leader Shaping Corporate Workforce Dynamics
TRAINNING, DEVELOPMENT AND APPRAISAL.pptx
Slide gioi thieu VietinBank Quy 2 - 2025
Chapter 2 - AI chatbots and prompt engineering.pdf
Booking.com The Global AI Sentiment Report 2025
Daniels 2024 Inclusive, Sustainable Development
Satish NS: Fostering Innovation and Sustainability: Haier India’s Customer-Ce...
ICv2 White Paper - Gen Con Trade Day 2025
Robin Fischer: A Visionary Leader Making a Difference in Healthcare, One Day ...
Charisse Litchman: A Maverick Making Neurological Care More Accessible
operations management : demand supply ch
Solaris Resources Presentation - Corporate August 2025.pdf
FINALS-BSHhchcuvivicucucucucM-Centro.docx
BUSINESS CYCLE_INFLATION AND UNEMPLOYMENT.pptx
interschool scomp.pptxzdkjhdjvdjvdjdhjhieij
Astra-Investor- business Presentation (1).pptx
PMB 401-Identification-of-Potential-Biotechnological-Products.pdf
THE COMPLETE GUIDE TO BUILDING PASSIVE INCOME ONLINE
Lecture 3344;;,,(,(((((((((((((((((((((((

Insertarbotones en c

  • 1. Insertarbotones en c# using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace ClaseMiercoles29mayo { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void butBuscar_Click(object sender, EventArgs e) { string conexion = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:basevendedores.accdb"; //Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:UsersCoodinacionDocumentsDatabase2.accdb;Persist Security Info=False"; string ssql = "Select * From Tabla1 where Idv =" + Int32.Parse(textId.Text); OleDbDataAdapter da = new OleDbDataAdapter(ssql, conexion);
  • 2. OleDbCommandBuilder cb = new OleDbCommandBuilder(da); DataTable dt = new DataTable(); da.Fill(dt); int fila1 = 0; if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[fila1]; textNombre.Text = dr["vNombre"].ToString(); OleDbDataAdapter da2 = new OleDbDataAdapter("select * from Tabla1", conexion); OleDbCommandBuilder cb2 = new OleDbCommandBuilder(da2); //DataTable dt2 = new DataTable(); DataSet dsDatos = new DataSet(); da2.Fill(dsDatos, "Vendedores"); this.dataGridView1.DataMember = "Vendedores"; this.dataGridView1.DataSource = dsDatos; } else { textNombre.Text = ""; MessageBox.Show("No hay datos"); } }
  • 3. private void buttInsertar_Click(object sender, EventArgs e) { string conexion = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:basevendedores.accdb"; string vSql = "Insert into Tabla1 (idv, VNombre) values ( " + Int32.Parse(textId.Text) + " ,'" + textNombre.Text + "')"; OleDbConnection miConeccion = new OleDbConnection(conexion); OleDbCommand miComando = new OleDbCommand(vSql); miComando.Connection = miConeccion; miConeccion.Open(); miComando.ExecuteNonQuery(); miComando.Connection.Close(); MessageBox.Show("Alumo Agregado exitosamente"); } private void buttActualizar_Click(object sender, EventArgs e) { string conexion = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:basevendedores.accdb"; string vSql = "Update Tabla1 set VNOmbre = '" + textNombre.Text + "'" + " where Idv =" + Int32.Parse(textId.Text); OleDbConnection miConeccion = new OleDbConnection(conexion); OleDbCommand miComando = new OleDbCommand(vSql); miComando.Connection = miConeccion; miConeccion.Open(); miComando.ExecuteNonQuery(); miComando.Connection.Close(); MessageBox.Show("Alumo Actualizado exitosamente"); }
  • 4. private void buttEliminar_Click(object sender, EventArgs e) { string conexion = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:basevendedores.accdb"; string vSql = "Delete from Tabla1 where Idv =" + Int32.Parse(textId.Text); OleDbConnection miConeccion = new OleDbConnection(conexion); OleDbCommand miComando = new OleDbCommand(vSql); miComando.Connection = miConeccion; miConeccion.Open(); miComando.ExecuteNonQuery(); miComando.Connection.Close(); MessageBox.Show("Alumo Eliminado exitosamente"); } } }