My code Hidden code in C# is:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace scuoleusr
{
/// <summary>
/// Summary description for WebForm5.
/// </summary>
public class WebForm5 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox Pippo;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Pippo.TextChanged += new System.EventHandler(this.TextBox1_TextChanged);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void TextBox1_TextChanged(object sender, System.EventArgs e)
{
}
private void Button1_Click(object sender, System.EventArgs e)
{
SqlConnection connection = new SqlConnection("server=sqlservdida.csr.unibo.it;Trusted_Connection=false;database=scuole_usr;uid=redazioneusr_db;pwd=********");
try
{
connection.Open();
SqlCommand command = new SqlCommand("insert into burattif.NumeriProva (Numeri) " +
"values ("& Pippo.Text &")", connection);
command.ExecuteNonQuery();
}
catch (Exception)
{
}
finally
{
connection.Close();
}
}
}
}
The connection to SQLServer DB is ok .....but i can insert the record in the database!
"Pippo" is ID of a TextBox.
Help me, please.
Francesco
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace scuoleusr
{
/// <summary>
/// Summary description for WebForm5.
/// </summary>
public class WebForm5 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox Pippo;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Pippo.TextChanged += new System.EventHandler(this.TextBox1_TextChanged);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void TextBox1_TextChanged(object sender, System.EventArgs e)
{
}
private void Button1_Click(object sender, System.EventArgs e)
{
SqlConnection connection = new SqlConnection("server=sqlservdida.csr.unibo.it;Trusted_Connection=false;database=scuole_usr;uid=redazioneusr_db;pwd=********");
try
{
connection.Open();
SqlCommand command = new SqlCommand("insert into burattif.NumeriProva (Numeri) " +
"values ("& Pippo.Text &")", connection);
command.ExecuteNonQuery();
}
catch (Exception)
{
}
finally
{
connection.Close();
}
}
}
}
The connection to SQLServer DB is ok .....but i can insert the record in the database!
"Pippo" is ID of a TextBox.
Help me, please.
Francesco