Please Help with this Code... - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Please Help with this Code...

[b][red]This message was edited by smdrc4 at 2005-1-31 14:6:8[/red][/b][hr]
I have this code:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Project3
{
///
/// Summary description for WinForm.
///
public class WinForm : System.Windows.Forms.Form
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
private System.Windows.Forms.DataGrid dataGrid1;
private Borland.Data.Provider.BdpConnection bdpConnection1;
private Borland.Data.Provider.BdpDataAdapter bdpDataAdapter1;
private Borland.Data.Provider.BdpCommand bdpSelectCommand1;
private System.Data.DataSet dataSet1;
private Borland.Data.Provider.BdpCommand bdpCommand1;
private System.Data.DataTable dataTable1;
private System.Data.DataColumn dataColumn1;
private System.Data.DataColumn dataColumn2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
public Borland.Data.Provider.BdpCommand bdpCommand2;

public WinForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///
/// Clean up any resources being used.
///
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataTable1 = new System.Data.DataTable();
this.dataColumn1 = new System.Data.DataColumn();
this.dataColumn2 = new System.Data.DataColumn();
this.bdpConnection1 = new Borland.Data.Provider.BdpConnection();
this.bdpDataAdapter1 = new Borland.Data.Provider.BdpDataAdapter();
this.dataSet1 = new System.Data.DataSet();
this.bdpSelectCommand1 = new Borland.Data.Provider.BdpCommand();
this.bdpCommand1 = new Borland.Data.Provider.BdpCommand();
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.bdpCommand2 = new Borland.Data.Provider.BdpCommand();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataTable1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bdpDataAdapter1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.DataSource = this.dataTable1;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(264, 16);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(264, 144);
this.dataGrid1.TabIndex = 0;
//
// dataTable1
//
this.dataTable1.Columns.AddRange(new System.Data.DataColumn[] {
this.dataColumn1,
this.dataColumn2});
this.dataTable1.Constraints.AddRange(new System.Data.Constraint[] {
new System.Data.UniqueConstraint("Constraint1", new string[] {
"NCONTROL"}, true)});
this.dataTable1.PrimaryKey = new System.Data.DataColumn[] {
this.dataColumn1};
this.dataTable1.TableName = "ALUMNO";
//
// dataColumn1
//
this.dataColumn1.AllowDBNull = false;
this.dataColumn1.ColumnName = "NCONTROL";
this.dataColumn1.MaxLength = 9;
//
// dataColumn2
//
this.dataColumn2.ColumnName = "NOMBRE";
this.dataColumn2.MaxLength = 9;
//
// bdpConnection1
//
this.bdpConnection1.ConnectionOptions = "waitonlocks=False;commitretain=False;sqldialect=3;transaction isol" +
"ation=ReadCommitted;servercharset=;rolename=myrole";
this.bdpConnection1.ConnectionString = "database=D:\Borland\InterBse\bin\ESCUELA.GDB;assembly=Borland.Data" +
".Interbase,Version=2.0.0.0,Culture=neutral,PublicKeyToken=91d62eb" +
"b5b0d1b1b;vendorclient=gds32.dll;provider=Interbase;username=sysd" +
"ba;password=masterkey";
//
// bdpDataAdapter1
//
this.bdpDataAdapter1.Active = true;
this.bdpDataAdapter1.DataSet = this.dataSet1;
this.bdpDataAdapter1.DataTable = this.dataTable1;
this.bdpDataAdapter1.SelectCommand = this.bdpSelectCommand1;
this.bdpDataAdapter1.StartRecord = 0;
this.bdpDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "ALUMNO", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("NCONTROL", "NCONTROL"),
new System.Data.Common.DataColumnMapping("NOMBRE", "NOMBRE")})});
this.bdpDataAdapter1.UpdateCommand = this.bdpCommand1;
//
// dataSet1
//
this.dataSet1.DataSetName = "NewDataSet";
this.dataSet1.Locale = new System.Globalization.CultureInfo("es-MX");
this.dataSet1.Tables.AddRange(new System.Data.DataTable[] {
this.dataTable1});
//
// bdpSelectCommand1
//
this.bdpSelectCommand1.CommandOptions = null;
this.bdpSelectCommand1.CommandText = "SELECT NCONTROL, NOMBRE FROM ALUMNO";
this.bdpSelectCommand1.CommandType = System.Data.CommandType.Text;
this.bdpSelectCommand1.Connection = this.bdpConnection1;
this.bdpSelectCommand1.ParameterCount = ((short)(0));
this.bdpSelectCommand1.SchemaName = null;
this.bdpSelectCommand1.Transaction = null;
this.bdpSelectCommand1.UpdatedRowSource = System.Data.UpdateRowSource.None;
//
// bdpCommand1
//
this.bdpCommand1.CommandOptions = null;
this.bdpCommand1.CommandText = null;
this.bdpCommand1.CommandType = System.Data.CommandType.Text;
this.bdpCommand1.Connection = null;
this.bdpCommand1.ParameterCount = ((short)(0));
this.bdpCommand1.SchemaName = null;
this.bdpCommand1.Transaction = null;
this.bdpCommand1.UpdatedRowSource = System.Data.UpdateRowSource.None;
//
// button1
//
this.button1.Location = new System.Drawing.Point(264, 184);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(72, 24);
this.button1.TabIndex = 1;
this.button1.Text = "Alta";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 48);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(104, 16);
this.label1.TabIndex = 2;
this.label1.Text = "Nmero de control";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 96);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(48, 16);
this.label2.TabIndex = 3;
this.label2.Text = "Nombre";
//
// label3
//
this.label3.Location = new System.Drawing.Point(8, 152);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 24);
this.label3.TabIndex = 4;
this.label3.Text = "Primer apellido";
//
// label4
//
this.label4.Location = new System.Drawing.Point(8, 216);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(96, 24);
this.label4.TabIndex = 5;
this.label4.Text = "Segundo apellido";
//
// label5
//
this.label5.Location = new System.Drawing.Point(8, 272);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(48, 24);
this.label5.TabIndex = 6;
this.label5.Text = "Carrera";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(112, 48);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 7;
this.textBox1.Text = "";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(112, 96);
this.textBox2.Name = "textBox2";
this.textBox2.TabIndex = 8;
this.textBox2.Text = "";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(112, 152);
this.textBox3.Name = "textBox3";
this.textBox3.TabIndex = 9;
this.textBox3.Text = "";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(112, 216);
this.textBox4.Name = "textBox4";
this.textBox4.TabIndex = 10;
this.textBox4.Text = "";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(112, 272);
this.textBox5.Name = "textBox5";
this.textBox5.TabIndex = 11;
this.textBox5.Text = "";
//
// button2
//
this.button2.Location = new System.Drawing.Point(264, 224);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(72, 24);
this.button2.TabIndex = 12;
this.button2.Text = "Baja";
//
// button3
//
this.button3.Location = new System.Drawing.Point(360, 184);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(80, 24);
this.button3.TabIndex = 13;
this.button3.Text = "Modificacin";
//
// button4
//
this.button4.Location = new System.Drawing.Point(360, 224);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(80, 24);
this.button4.TabIndex = 14;
this.button4.Text = "Salir";
//
// bdpCommand2
//
this.bdpCommand2.CommandOptions = null;
this.bdpCommand2.CommandText = "INSERT INTO ALUMNO (NCONTROL) VALUES('1')";
this.bdpCommand2.CommandType = System.Data.CommandType.Text;
this.bdpCommand2.Connection = this.bdpConnection1;
this.bdpCommand2.ParameterCount = ((short)(1));
this.bdpCommand2.Parameters.Add(new Borland.Data.Common.BdpParameter("NCONTROL", Borland.Data.Common.BdpType.String, Borland.Data.Common.BdpType.String, 0, System.Data.ParameterDirection.Input, false, ((byte)(8)), ((byte)(0)), 8, "NCONTROL", System.Data.DataRowVersion.Current, null));
this.bdpCommand2.SchemaName = "";
this.bdpCommand2.Transaction = null;
this.bdpCommand2.UpdatedRowSource = System.Data.UpdateRowSource.Both;
//
// WinForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(552, 358);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGrid1);
this.Name = "WinForm";
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataTable1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bdpDataAdapter1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();
this.ResumeLayout(false);
}
#endregion

///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new WinForm());
}

private void button1_Click(object sender, System.EventArgs e)
{
if(this.textBox1.Text=="")
MessageBox.Show("No se puede insertar");
else
{
bdpConnection1.Open();
bdpCommand2.ExecuteNonQuery();
MessageBox.Show("Ha sido insertado el campo");
bdpConnection1.Close();
}
}
}
}

but, when i want to run this project and i click the button that makes a call to this last function, i get a: Project Project3.exe encountered unhandled exception class Borland.Data.Common.BdpException with message 'Execute failed. unassigned code'.

So i can't make this thing work when i click the button1 showed before...

Please help...

i forgot to write, i'm using Borland Delphi Studio 9 and if i need to post the properties of the componentes, well i hope you tell me what i need to put here
Sign In or Register to comment.