Hola disculpen que les moleste estoy empesando a programar con Base de datos en SQL y necesito que de favor me ayuden con esto.Tengo una base de datos y necesito presentar esos datos en un formulario eso ya lo hice (El Boton cargar y Mostrar ya estan) lo que no puedo programar es el boton siguiente(tiene que presentar los datos del siguiente usuario) , el boton atras
(tiene que presentar los datos del usuario anterior al actual) y el boton buscar(tiene que presentar los datos del usuario del cual se ingresa el numero de cedula en el textbox) yo se que ustedes pueden ayudarme y les estare muy agradecido Chao. (esto en C# 2003 ahi les envio el codigo para que lo entiendan mejor).[using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Deber
{
/// <summary>
/// Descripción breve de Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
int i=0;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Data.SqlClient.SqlCommand sqlCommand1;
private mazo.DataSet1 dataSet11;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.TextBox textBox3;
/// <summary>
/// Variable del diseñador requerida.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Necesario para admitir el Diseñador de Windows Forms
//
InitializeComponent();
//
// TODO: agregar código de constructor después de llamar a InitializeComponent
//
}
/// <summary>
/// Limpiar los recursos que se estén utilizando.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Código generado por el Diseñador de Windows Forms
/// <summary>
/// Método necesario para admitir el Diseñador. No se puede modificar
/// el contenido del método con el editor de código.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
this.dataSet11 = new mazo.DataSet1();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.button3 = new System.Windows.Forms.Button();
this.textBox3 = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(40, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 23);
this.label1.TabIndex = 0;
this.label1.Text = "Cedula";
//
// label3
//
this.label3.Location = new System.Drawing.Point(40, 80);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 23);
this.label3.TabIndex = 2;
this.label3.Text = "Nombre";
//
// label4
//
this.label4.Location = new System.Drawing.Point(48, 120);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 23);
this.label4.TabIndex = 3;
this.label4.Text = "Fono";
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(40, 208);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(72, 32);
this.button1.TabIndex = 5;
this.button1.Text = "CARGAR";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(136, 208);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(88, 32);
this.button2.TabIndex = 6;
this.button2.Text = "MOSTRAR";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(104, 40);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(168, 20);
this.textBox1.TabIndex = 8;
this.textBox1.Text = "";
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(112, 72);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(256, 20);
this.textBox2.TabIndex = 9;
this.textBox2.Text = "";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(40, 256);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(200, 20);
this.textBox4.TabIndex = 11;
this.textBox4.Text = "";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.textBox2);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.textBox3);
this.groupBox1.Location = new System.Drawing.Point(32, 32);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(384, 168);
this.groupBox1.TabIndex = 13;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "DATOS";
//
// groupBox2
//
this.groupBox2.Location = new System.Drawing.Point(920, 16);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(344, 240);
this.groupBox2.TabIndex = 13;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "groupBox1";
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("es-ES");
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=\"CRISTIAN-X8R826\";packet size=4096;integrated security=SSPI;data s" +
"ource=\"(local)\";persist security info=False;initial catalog=Base de datos Deber";
//
// button4
//
this.button4.Location = new System.Drawing.Point(240, 208);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(72, 32);
this.button4.TabIndex = 14;
this.button4.Text = "Siguiente";
//
// button5
//
this.button5.Location = new System.Drawing.Point(328, 208);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(80, 32);
this.button5.TabIndex = 15;
this.button5.Text = "Atras";
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Usuario", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("id", "id"),
new System.Data.Common.DataColumnMapping("nombre", "nombre"),
new System.Data.Common.DataColumnMapping("cedula", "cedula"),
new System.Data.Common.DataColumnMapping("fono", "fono")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT id, nombre, cedula, fono FROM Usuario";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// button3
//
this.button3.Location = new System.Drawing.Point(240, 256);
this.button3.Name = "button3";
this.button3.TabIndex = 16;
this.button3.Text = "Buscar";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(80, 120);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(136, 20);
this.textBox3.TabIndex = 17;
this.textBox3.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.IndianRed;
this.ClientSize = new System.Drawing.Size(448, 326);
this.Controls.Add(this.button3);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox4);
this.Name = "Form1";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
this.Text = "Datos ";
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// Punto de entrada principal de la aplicación.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(!Char.IsDigit(e.KeyChar))
{
e.Handled=true;
}
}
private void button1_Click(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(dataSet11);
}
private void button2_Click(object sender, System.EventArgs e )
{
textBox1.DataBindings.Add("Text",dataSet11,"Usuario.cedula");
textBox2.DataBindings.Add("Text",dataSet11,"Usuario.nombre");
textBox3.DataBindings.Add("Text",dataSet11,"Usuario.fono");
}
}
}
]





