|
public int update_register(int id, string fill_by, string email, string password, string gender, string pacakage, string pay_mode)
{
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand("updateregister", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection.Open();
cmd.Parameters.AddWithValue("@id", id);
cmd.Parameters.AddWithValue("@fill_by", fill_by);
cmd.Parameters.AddWithValue("@email", email);
cmd.Parameters.AddWithValue("@password", password);
cmd.Parameters.AddWithValue("@gender", gender);
cmd.Parameters.AddWithValue("@pacakage", pacakage);
cmd.Parameters.AddWithValue("@pay_mode", pay_mode);
return cmd.ExecuteNonQuery ();
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//DataList1.DataSource = bindlist();
DataList1.DataSource = DataBind();
DataList1.DataBind();
}
DataBind();
}
public DataTable DataBind()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["yahooConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("select id,fill_by,email,password,gender,pacakage,pay_mode from register ", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "register");
return ds.Tables["register"];
}
protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
{
Rock ab=new Rock() ;
int id = Convert.ToInt32(DataList1.DataKeys[e.Item.ItemIndex].ToString());
string fill_by = ((DropDownList)e.Item.FindControl("DropdownList1")).SelectedItem.Text.ToString();
string email = ((TextBox)e.Item.FindControl("TextBox1")).Text;
string password = ((TextBox)e.Item.FindControl("TextBox2")).Text;
string gender = ((DropDownList)e.Item.FindControl("DropDownList2")).SelectedItem.Text.ToString();
string pacakage = ((DropDownList)e.Item.FindControl("DropDownList3")).SelectedItem.Text.ToString();
string pay_mode = ((DropDownList)e.Item.FindControl("DropDownList4")).SelectedItem.Text.ToString();
int result = ab.update_register(id, fill_by, email, password, gender, pacakage, pay_mode);
if (result > 0)
{
Response.Write("Update Succesfully.");
}
else
{
Response.Write("Not Update..");
}
DataList1.EditItemIndex = -1;
DataList1.DataSource = DataBind();
DataList1.DataBind();
}
protected void DataList1_CancelCommand(object source, DataListCommandEventArgs e)
{
DataList1.EditItemIndex = -1;
DataList1.DataSource = DataBind();
DataList1.DataBind();
}
protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
{
DataList1.EditItemIndex = e.Item.ItemIndex;
DataList1.DataSource = DataBind();
DataList1.DataBind();
}
|
|
|
|
|
Session id = System.Convert.ToInt32(Session["estimate_id"]);
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString);
{
SqlCommand cmd1 = new SqlCommand();
cmd1.Connection = con;
cmd1.CommandText = "select * from tender where estimate_id='" + id + "'";
cmd1.CommandType = CommandType.Text;
SqlDataAdapter adp1 = new SqlDataAdapter();
adp1.SelectCommand = cmd1;
DataSet1 ds1 = new DataSet1();
adp1.Fill(ds1, "tender");
ReportDocument rpt1 = new ReportDocument();
rpt1.Load(Server.MapPath("CrystalReport1.rpt"));
rpt1.SetDataSource(ds1);
CrystalReportViewer1.ReportSource = rpt1;
CrystalReportViewer1.Visible = true;
}
|
|
|
|
|
Rock d = new Rock () ;
string father_name = TextBox8.Text;
string father_occupation = TextBox13.Text;
string mother_name = TextBox9.Text;
string mother_occupation = TextBox14.Text;
string brother = DropDownList33.SelectedItem.Text;
string brother_married = DropDownList35.SelectedItem.Text;
string sister = DropDownList34.SelectedItem.Text;
string sister_married = DropDownList36.SelectedItem .Text ;
int result=d.save_submit(father_name ,father_occupation ,mother_name ,mother_occupation ,brother ,brother_married ,sister ,sister_married );
if (result > 0)
{
Response.Write("successprofile.aspx");
}
else
{
Response.Write("notsuccess.aspx");
}
}
|
|
|
|
|
ALTER PROCEDURE dbo.save_submit
@pfather_name nvarchar(50),
@pfather_occupation nvarchar(50),
@pmother_name nvarchar(50),
@pmother_occupation nvarchar(50),
@pbrother nvarchar(50),
@pbrother_married nvarchar(50),
@psister nvarchar(50),
@psister_married nvarchar(50)
AS
insert into seven(father_name,father_occupation,mother_name,mother_occupation,brother,brother_married,sister,sister_married)
values(@pfather_name,@pfather_occupation,@pmother_name,@pmother_occupation,@pbrother,@pbrother_married,@psister,@psister_married)
RETURN
Step 3:-Create a class :-
public class Rock
{
string str = ConfigurationManager.ConnectionStrings["DataBaseConnectionString"].ConnectionString;
public Rock()
{
}
public int save_submit(string father_name, string father_occupation, string mother_name, string mother_occupation, string brother, string brother_married, string sister, string sister_married)
{
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand("save_submit", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection.Open();
cmd.Parameters.AddWithValue("@pfather_name", father_name);
cmd.Parameters.AddWithValue("@pfather_occupation", father_occupation);
cmd.Parameters.AddWithValue("@pmother_name", mother_name);
cmd.Parameters.AddWithValue("@pmother_occupation", mother_occupation);
cmd.Parameters.AddWithValue("@pbrother", brother);
cmd.Parameters.AddWithValue("@pbrother_married", brother_married);
cmd.Parameters.AddWithValue("@psister", sister);
cmd.Parameters.AddWithValue("@psister_married", sister_married);
return cmd.ExecuteNonQuery();
cmd.Connection.Close();
}
}
|
|
|
|
|
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('label4').innerHTML=h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
<body onload ="startTime()">
|
|
|
|
|
Image large on double click
<img src="IMAGES/groom1.jpg" alt="" width="150" height="200" onclick ="this.src='IMAGES/groom1.jpg';this.height=400;this.width=300" ondblclick ="this.src='IMAGES/groom1.jpg';this.height=200;this.width=150"/>
Image large on Mouse Over click
<img src="IMAGES/groom1.jpg" alt="" width="150" height="200" onmouseover ="this.src='IMAGES/groom1.jpg';this.height=400;this.width=300" onmouseout ="this.src='IMAGES/groom1.jpg';this.height=200;this.width=150"/>
Refresh asp page by deafult
Response.addheader(“refresh””5”)
|
|
|
|
|
function ValidateEmail()
{
//For Email. Validation
var EmaiAddress=document.getElementById("txtemail").value;
var RegExEmail = /^(?:\w+\.?)*\w+@(?:\w+\.)+\w+$/;
if (!RegExEmail.test(EmaiAddress))
{
alert("Please Enter Valid E-mail Adress");
//EmaiAddress=document.getElementById("txtemail").focus();
return false;
}
if(document .getElementById ("txtname").value=="")
{
alert("Enter Your Name.");
document.getElementById ("txtname").focus();
return false;
}
|
|
|
|
|
var Url="^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"
var tempURL=document.getElementById("<%=txtWebURL.ClientID%>").value;
var matchURL=tempURL.match(Url);
if(matchURL==null)
{
alert("Web URL does not look valid");
document.getElementById("<%=txtWebURL.ClientID %>").focus();
return false;
}
else
{
alert("Go Ahead!");
}
}
|
|
|
|
|
It cahange link color when mouse over
.a
{
float:left;
margin-left: 2em;
}
a:hover
{
color: #00F; /* Using blue here */
text-decoration: none; /* eliminates underline */
}
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
{
DataBind();
}
public void DataBind()
{
PagedDataSource page = new PagedDataSource();
page .AllowPaging =true ;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["yahooConnectionString"].ConnectionString);
SqlCommand cmd=new SqlCommand ("select id,fill_by,email,password,gender,pacakage,pay_mode from register ",con);
SqlDataAdapter da=new SqlDataAdapter (cmd );
DataSet ds=new DataSet ();
da.Fill (ds,"register");
page.DataSource =ds.Tables ["register"].DefaultView;
page .PageSize =2;
page .CurrentPageIndex = CurrentPage ;
DataList1 .DataSource =page ;
DataList1 .DataBind ();
}
public int CurrentPage
{
get
{
// look for current page in ViewState
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 0; // default to showing the first page
else
return (int)o;
}
set
{
this.ViewState["_CurrentPage"] = value;
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
CurrentPage -= 1;
DataBind();
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
CurrentPage += 1;
DataBind();
if (page.IsLastPage)
{
LinkButton2_Click = false;
}
}
|
|
|
|
|
session["name"]=textbox1.text \\create session in one page
textbox2.text=seesion["name"].tostring(); //like we can call the session value
Session["ans"] = ans;
Session["total"] = total;
|
|
|
|
|
Response.Redirect("practical.aspx?name="+TextBox1.Text+" &city="+TextBox2 .Text ); \\create QueryString in one page
TextBox9.Text = Request.QueryString["name"];
TextBox10.Text = Request.QueryString["city"];//like we can call the QueryString value
|
|
|
|
|
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
{
SqlCommand cmd1 = new SqlCommand();
cmd1.Connection = con;
cmd1.CommandText = "select * from personal1 where emp_id='" + DropDownList1.SelectedValue + "'";
cmd1.CommandType = CommandType.Text;
SqlDataAdapter adp1 = new SqlDataAdapter();
adp1.SelectCommand = cmd1;
DataSet1 ds1 = new DataSet1();
adp1.Fill(ds1, "personal1");
ReportDocument rpt1 = new ReportDocument();
rpt1.Load(Server.MapPath("CrystalReport1.rpt"));
rpt1.SetDataSource(ds1);
CrystalReportViewer1.ReportSource = rpt1;
CrystalReportViewer1.Visible = true;
}
|
|
|
|
|
<object style="height: 101px; width: 750px" class="style1">
<param name="movie" value="IMAGES/euro/euro.swf">
<embed src="IMAGES/euro/euro.swf" width="720" height="100">
</embed>
</object>
|
|
|
|
|
string myHost = System.Net.Dns.GetHostName();
string str = System.Net.Dns.GetHostByName(myHost).AddressList[0].ToString();
//Response.Write(myHost);
Response.Write(str);
|
|
|
|
|
Dim objConnection As Data.OleDb.OleDbConnection
Dim objCmd As Data.OleDb.OleDbCommand
Dim strConnection As String
Dim strSQL As String
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" + MapPath("database2.mdb")
' Create and open the connection object
objConnection = New Data.OleDb.OleDbConnection(strConnection)
objConnection.Open()
' set the SQL string
strSQL = "INSERT INTO table1(id,name1,address)" & _
" VALUES ( '" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "')"
' Create the Command and set its properties
objCmd = New Data.OleDb.OleDbCommand(strSQL, objConnection)
' execute the command
objCmd.ExecuteNonQuery()
Label4.Text = "Command run"
|
|
|
|
|
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" + MapPath("database2.mdb")
' Create and open the connection object
objConnection = New Data.OleDb.OleDbConnection(strConnection)
objConnection.Open()
' set the SQL string
strSQL = "update table1 set name1='" & TextBox2.Text & "',address='" & TextBox3.Text & "' where id = " & TextBox1.Text & ""
' Create the Command and set its properties
objCmd = New Data.OleDb.OleDbCommand(strSQL, objConnection)
' execute the command
objCmd.ExecuteNonQuery()
Label4.Text = "RECORD IS UPDATED"
|
|
|
|
|
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" + MapPath("database2.mdb")
' Create and open the connection object
objConnection = New Data.OleDb.OleDbConnection(strConnection)
objConnection.Open()
' set the SQL string
strSQL = "delete from table1 where id = " & TextBox1.Text & ""
' Create the Command and set its properties
objCmd = New Data.OleDb.OleDbCommand(strSQL, objConnection)
' execute the command
objCmd.ExecuteNonQuery()
Label4.Text = "RECORD IS DELETED"
|
|
|
|
|
using System.Data.SqlClient;
SqlConnection con1 = new SqlConnection("Data Source=INFOTECH-YP9BUE\\INFOTECHAHM;Initial Catalog=database1;Integrated Security=True");
SqlCommand cmd1 = new SqlCommand("Insert into table1(id,name,address,age)values(@p1,@p2,@p3,@p4)", con1);
cmd1.Connection.Open();
cmd1.Parameters.Add("@p1", SqlDbType.Int).Value = TextBox1.Text;
cmd1.Parameters.Add("@p2", SqlDbType.NChar).Value = TextBox2.Text;
cmd1.Parameters.Add("@p3", SqlDbType.NChar).Value = TextBox3.Text;
cmd1.Parameters.Add("@p4", SqlDbType.Int).Value = DropDownList1.SelectedItem.ToString();
cmd1.ExecuteNonQuery();
cmd1.Connection.Close();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
Response.Write("Record in inserted");
}
|
|
|
|
|
SqlConnection con1 = new SqlConnection("Data Source=INFOTECH-YP9BUE\\INFOTECHAHM;Initial Catalog=database1;Integrated Security=True");
string str2 = "select name,address,age from table1 where id='" + TextBox1.Text + "'";
SqlCommand cmd1 = new SqlCommand(str2, con1);
cmd1.Connection.Open();
SqlDataReader r1 = cmd1.ExecuteReader();
//TextBox3.Text = "";
//while (r1.Read())
//{ TextBox2.Text = r1.GetValue(0).ToString();
// TextBox3.Text = r1.GetValue(1).ToString();
// Response.Write("Record is opened");
// }
if (r1.Read())
{
TextBox2.Text = r1.GetValue(0).ToString();
TextBox3.Text = r1.GetValue(1).ToString();
DropDownList1.Text = r1.GetValue(2).ToString();
//DropDownList1.Items = r1.GetValue(2).ToString();
Response.Write("Record is opened");
}
else
{
TextBox2.Text = "";
TextBox3.Text = "";
Response.Write("Invalid id");
}
r1.Close();
cmd1.Connection.Close();
}
|
|
|
|
|
SqlConnection con1 = new SqlConnection("Data Source=INFOTECH-YP9BUE\\INFOTECHAHM;Initial Catalog=database1;Integrated Security=True");
string str2 = "delete from table1 where id='" + TextBox1.Text + "'";
SqlCommand cmd1 = new SqlCommand(str2, con1);
cmd1.Connection.Open();
SqlDataReader r1 = cmd1.ExecuteReader();
if (r1.Read())
{
Response.Write("Record is DEleted");
}
else
{
TextBox2.Text = "";
TextBox3.Text = "";
Response.Write("Invalid id");
}
r1.Close();
cmd1.Connection.Close();
|
|
|
|
|
SqlConnection con = new SqlConnection("Data Source=INFOTECH-EDF71E\\SQLEXPRESS;Initial Catalog=grid;Integrated Security=True;Pooling=False");
SqlDataAdapter ad = new SqlDataAdapter("select * from customer WHERE name='" + TextBox1.Text+ "'",con);
DataSet ds = new DataSet();
ad.Fill(ds, "customer");
GridView1.DataSource = ds ;
GridView1.DataBind();
|
|
|
|
|
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs("E:\\pradeep_Document\\WebSite1\\new\\" + FileUpload1.FileName + ".jpg");
Label1.Text = "name=" + FileUpload1.FileName + "type=" + FileUpload1.PostedFile.ContentType + "size" + FileUpload1.PostedFile.ContentLength;
}
else
{
Label1.Text = "Selct image";
}
//if (FileUpLoad1.HasFile)
//{
// //Uncomment this line to Save the uploaded file
// //FileUpLoad1.SaveAs("C:\SomePhysicalPath" + FileUpLoad1.Filename);
// Label1.Text = "Received " + FileUpLoad1.FileName + " Content Type " + FileUpLoad1.PostedFile.ContentType + " Length " + FileUpLoad1.PostedFile.ContentLength;
//}
//else
//{
// Label1.Text = "No uploaded file";
//}
|
|
|
|
|
Define Variable
Dim myConnection As New SqlClient.SqlConnection
Dim myCommand As New SqlClient.SqlCommand
Dim ra As Integer
Dim dr As SqlClient.SqlDataReader
Dim str As String
Insert Querry
myConnection = New SqlClient.SqlConnection("Data Source=INFOTECH-YP9BUE\INFOTECHAHM;Initial Catalog=rock;Persist Security Info=True;User ID=sa; password=sa;Pooling=False")
'you need to provide password for sql server
myConnection.Open()
str = "Insert into adddata values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "')"
myCommand = New SqlClient.SqlCommand(str, myConnection)
ra = myCommand.ExecuteNonQuery()
MessageBox.Show("New Row Inserted")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
myConnection.Close()
|
|
|
|
|