Stored procedures sample program

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace Stored_Proc
{
public partial class WebForm1 : System.Web.UI.Page
{

//DataSet ds = new DataSet();

SqlConnection con;

SqlCommand cmd = new SqlCommand();

//SqlParameter sp1 = new SqlParameter();
//SqlParameter sp2 = new SqlParameter();
//SqlParameter sp3 = new SqlParameter();
//SqlParameter sp4 = new SqlParameter();

protected void Page_Load(object sender, EventArgs e)
{
Label6.Text = null;

doSomething();
}

protected void Button1_Click(object sender, EventArgs e)
{
con = new SqlConnection(“Data Source=KUSHANLAHIRU-PC;Initial Catalog=example1;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False”);
cmd = new SqlCommand(“Splogin”, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(“@ID”, SqlDbType.VarChar).Value = TextBox1.Text;
cmd.Parameters.Add(“@Password”, SqlDbType.VarChar).Value = TextBox2.Text;
cmd.Parameters.Add(“@ConfirmPassword”, SqlDbType.VarChar).Value = TextBox3.Text;
cmd.Parameters.Add(“@EmailID”, SqlDbType.VarChar).Value = TextBox4.Text;

con.Open();
cmd.ExecuteNonQuery();
Label5.Text = “Successful”;

con.Close();
}

private void doSomething()
{
string str = null;
string retString = null;
str = “This is substring test”;
retString = str.Substring(8, 9);
//MessageBox.Show(retString);
Label6.Text = retString.ToString();
}

}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s