Sunday, November 15, 2009

Stored Procedure FOr Inserting Values

ALTER PROCEDURE [dbo].[usp_insertOrderDetails](
@UserName varchar(50),
@ProductName varchar(50),
@Cost varchar(50),
@Description varchar(50),
@Qty varchar(50),
@total varchar(50)
)
AS
BEGIN
SET NOCOUNT ON;

INSERT INTO dbo.[Order](
UserName,
ProductName,
Cost,
Description,
Qty,
Total,
Order_Date
)
VALUES
(
@UserName,
@ProductName,
@Cost,
@Description ,
@Qty,
@total ,
getdate()
)

END

Dynamically Creating Button With Placethe Place holder Container

protected void Page_Load(object sender, EventArgs e)
{
Button bt = new Button();
bt.Height = 20;
bt.Width = 40;
bt.Text = "submit";
PlaceHolder1.Controls.Add(bt);
bt.Click += new EventHandler(bt_Click);

}

Forgot Password Using Emails

Name Spaces:
using System.Net.Mail;
using System.IO;
using System.Drawing;
We Are Add the Web Reference In solution Explorar





protected void btnOk_Click(object sender, EventArgs e)
{
MailMessage mailMessage = new MailMessage("raju.mygo@gmail.com", txtEmailid .Text );
mailMessage.Subject = "Password Verification";

mailMessage.Body = "Raju";
SmtpClient smtpClient = new SmtpClient();


smtpClient.Host = "smtp.gmail.com";

smtpClient.Port = 587;
smtpClient.UseDefaultCredentials = true;

smtpClient.Credentials = new System.Net.NetworkCredential("raju.mygo@gmail.com","9959380293");

smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);
btnOk.ForeColor = Color.Red;
btnOk.Text = "password sent Sucessfully to Ur mail Id";


}

Searching Records Using Like operator

public void binddata()
{

SqlDataAdapter da = new SqlDataAdapter("Select * from enquiry where technologyaw like'" + TextBox1.Text + "%' ", con);
DataSet ds = new DataSet();
da.Fill(ds);


GridView1.DataSource = ds;
GridView1.DataBind();
}

Deleting Records Using Checkbox Control

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
binddata();
}
}



protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count;i++)
{

CheckBox ch = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
if (ch.Checked == true)
{
Label l1 = (Label)GridView1.Rows[i].FindControl("Label1");
con.Open();
SqlCommand cmd = new SqlCommand("delete from colldet where collegeid='" + l1.Text + "'", con);
cmd.ExecuteNonQuery();
con.Close();

}


}
binddata();

}