A
Auto
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Autocentras2
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Data.SqlClient.SqlConnection sqlConnection1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlDataAdapter aGamintojas;
private Autocentras2.ds_gam ds_gam1;
private System.Windows.Forms.Button button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.aGamintojas = new System.Data.SqlClient.SqlDataAdapter();
this.ds_gam1 = new Autocentras2.ds_gam();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.ds_gam1)).BeginInit();
this.SuspendLayout();
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=DALIUSXP;packet
size=4096;user id=sa;data source=\"DALIUSXP\\DALIUSS" +
"QLSERVER\";persist security info=False;initial catalog=AutocentrasDB";
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT Gamintojas_ID, Gamintojas FROM
TblGamintojas";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO TblGamintojas(Gamintojas)
VALUES (@Gamintojas); SELECT Gamintojas_ID," +
" Gamintojas FROM TblGamintojas WHERE (Gamintojas_ID = @@IDENTITY)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Gamintojas",
System.Data.SqlDbType.VarChar, 50, "Gamintojas"));
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE TblGamintojas SET Gamintojas =
@Gamintojas WHERE (Gamintojas_ID = @Original_Gamintojas_ID) AND (Gamintojas
= @Original_Gamintojas OR @Original_Gamintojas IS NULL AND Gamintojas IS
NULL); SELECT Gamintojas_ID, Gamintojas FROM TblGamintojas WHERE
(Gamintojas_ID = @Gamintojas_ID)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Gamintojas",
System.Data.SqlDbType.VarChar, 50, "Gamintojas"));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Gamintojas_ID",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false,
((System.Byte)(0)), ((System.Byte)(0)), "Gamintojas_ID",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Gamintojas",
System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Gamintojas",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Gamintojas_ID",
System.Data.SqlDbType.Int, 4, "Gamintojas_ID"));
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = "DELETE FROM TblGamintojas WHERE
(Gamintojas_ID = @Original_Gamintojas_ID) AND (Ga" +
"mintojas = @Original_Gamintojas OR @Original_Gamintojas IS NULL AND
Gamintojas I" +
"S NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Gamintojas_ID",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false,
((System.Byte)(0)), ((System.Byte)(0)), "Gamintojas_ID",
System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Gamintojas",
System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Gamintojas",
System.Data.DataRowVersion.Original, null));
//
// aGamintojas
//
this.aGamintojas.DeleteCommand = this.sqlDeleteCommand1;
this.aGamintojas.InsertCommand = this.sqlInsertCommand1;
this.aGamintojas.SelectCommand = this.sqlSelectCommand1;
this.aGamintojas.TableMappings.AddRange(new
System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "TblGamintojas", new
System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("Gamintojas_ID", "Gamintojas_ID"),
new System.Data.Common.DataColumnMapping("Gamintojas", "Gamintojas")})});
this.aGamintojas.UpdateCommand = this.sqlUpdateCommand1;
//
// ds_gam1
//
this.ds_gam1.DataSetName = "ds_gam";
this.ds_gam1.Locale = new System.Globalization.CultureInfo("lt-LT");
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 120);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(144, 23);
this.button1.TabIndex = 0;
this.button1.Text = "PildytiDataset";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(464, 334);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.ds_gam1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
//THIS DOES NOT WORK !!!!!!! WHY?
aGamintojas.Fill(ds_gam1);
}
}
}
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Autocentras2
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Data.SqlClient.SqlConnection sqlConnection1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlDataAdapter aGamintojas;
private Autocentras2.ds_gam ds_gam1;
private System.Windows.Forms.Button button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.aGamintojas = new System.Data.SqlClient.SqlDataAdapter();
this.ds_gam1 = new Autocentras2.ds_gam();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.ds_gam1)).BeginInit();
this.SuspendLayout();
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=DALIUSXP;packet
size=4096;user id=sa;data source=\"DALIUSXP\\DALIUSS" +
"QLSERVER\";persist security info=False;initial catalog=AutocentrasDB";
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT Gamintojas_ID, Gamintojas FROM
TblGamintojas";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO TblGamintojas(Gamintojas)
VALUES (@Gamintojas); SELECT Gamintojas_ID," +
" Gamintojas FROM TblGamintojas WHERE (Gamintojas_ID = @@IDENTITY)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Gamintojas",
System.Data.SqlDbType.VarChar, 50, "Gamintojas"));
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE TblGamintojas SET Gamintojas =
@Gamintojas WHERE (Gamintojas_ID = @Original_Gamintojas_ID) AND (Gamintojas
= @Original_Gamintojas OR @Original_Gamintojas IS NULL AND Gamintojas IS
NULL); SELECT Gamintojas_ID, Gamintojas FROM TblGamintojas WHERE
(Gamintojas_ID = @Gamintojas_ID)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Gamintojas",
System.Data.SqlDbType.VarChar, 50, "Gamintojas"));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Gamintojas_ID",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false,
((System.Byte)(0)), ((System.Byte)(0)), "Gamintojas_ID",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Gamintojas",
System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Gamintojas",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Gamintojas_ID",
System.Data.SqlDbType.Int, 4, "Gamintojas_ID"));
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = "DELETE FROM TblGamintojas WHERE
(Gamintojas_ID = @Original_Gamintojas_ID) AND (Ga" +
"mintojas = @Original_Gamintojas OR @Original_Gamintojas IS NULL AND
Gamintojas I" +
"S NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Gamintojas_ID",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false,
((System.Byte)(0)), ((System.Byte)(0)), "Gamintojas_ID",
System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Gamintojas",
System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Gamintojas",
System.Data.DataRowVersion.Original, null));
//
// aGamintojas
//
this.aGamintojas.DeleteCommand = this.sqlDeleteCommand1;
this.aGamintojas.InsertCommand = this.sqlInsertCommand1;
this.aGamintojas.SelectCommand = this.sqlSelectCommand1;
this.aGamintojas.TableMappings.AddRange(new
System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "TblGamintojas", new
System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("Gamintojas_ID", "Gamintojas_ID"),
new System.Data.Common.DataColumnMapping("Gamintojas", "Gamintojas")})});
this.aGamintojas.UpdateCommand = this.sqlUpdateCommand1;
//
// ds_gam1
//
this.ds_gam1.DataSetName = "ds_gam";
this.ds_gam1.Locale = new System.Globalization.CultureInfo("lt-LT");
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 120);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(144, 23);
this.button1.TabIndex = 0;
this.button1.Text = "PildytiDataset";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(464, 334);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.ds_gam1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
//THIS DOES NOT WORK !!!!!!! WHY?
aGamintojas.Fill(ds_gam1);
}
}
}