Sunday, November 2, 2008

Worked code For Reference

Create one table named emp
Write the stored procedure for the insertions of the table as


Create procedure insert_emp(@eid int,@ename varchar(20) as
Begin
Insert into emp values(@eid,@ename);
End

------------------------------------------------------------------------------------------------------------------------------------------------------
2.connection to sql server with connected architecture

//this is a connected architecture,in this we have to open connection and close connection
SqlConnection con = new SqlConnection("server=localhost;database=raja;integrated security=sspi");
string SqlCmd = "insert into friends5 values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "')";
SqlCommand cmd = new SqlCommand(SqlCmd, con);
con.Open();
cmd.ExecuteNonQuery();
Response.Write("values inserted");
con.Close();
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
sdlc

The software development life cycle (SDLC) is the entire process of formal, logical steps taken to develop a software product. The phases of SDLC generally include the following:

conceptualization;
requirements and cost/benefits analysis;
detailed specification of the software requirements;
software design;
programming;
testing;
user and technical training;
and maintenance.

Using datagrid,delete ,add,operations

For adding
SqlConnection con;
SqlDataAdapter da;
SqlCommandBuilder cmb;
DataSet ds = new DataSet();
DataRow row;
public void bind()
{
con = new SqlConnection("server=localhost;database=raja;integrated security=sspi");
da = new SqlDataAdapter("select * from ex", con);
cmb = new SqlCommandBuilder(da);
da.Fill(ds, "ex");
GridView1.DataSource = ds;
GridView1.DataBind();
da.Update(ds.Tables[0]);
ds.Tables[0].Constraints.Add("pik", ds.Tables[0].Columns[0]true);

}
for add button


protected void Button1_Click(object sender, EventArgs e)
{
row = ds.Tables[0].NewRow();
row[0] = TextBox1.Text;
row[1] = TextBox2.Text;
row[2] = TextBox3.Text;
ds.Tables[0].Rows.Add(row);
da.Update(ds.Tables[0]);
Response.Write("values inserted");
}
for delete
we have to bind the colums



">


">



we have to write script in data grid colums,






for deleting a row code is

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string ida=((Label)GridView1.Rows[e.RowIndex].FindControl("id")).Text;
int cid=Convert.ToInt32(ida);
con = new SqlConnection("server=localhost;database=raja;integrated security=sspi");
da = new SqlDataAdapter("delete from ex where id=" + cid + " ", con);
cmb = new SqlCommandBuilder(da);
da.Fill(ds, "ex");
GridView1.DataSource = ds;
GridView1.DataBind();
da.Update(ds.Tables[0]);
}
=====================================================================================


FOOTER TEMPLATE













For adding new record in the footer template placing add button and empty textboxes













for code is cs file
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Add")
{
//TextBox id1 = GridView1.FooterRow.FindControl("TextBox1") as TextBox;

string fir2 = ((TextBox)this.GridView1.FooterRow.FindControl("TextBox1")).Text;
string lname2 = ((TextBox)this.GridView1.FooterRow.FindControl("TextBox2")).Text;
string gen2 = ((TextBox)this.GridView1.FooterRow.FindControl("TextBox3")).Text;
}
}





==============================================================================simple login code

if ( textBox1.Text == "raja" && textBox2.Text == "bob")
{


Form2 objf2 = new Form2();
objf2.Show();
this.Visible = false;

}
else
{
MessageBox.Show("wrong cridentials");
}

for closing a browser window
Button5.Attributes.Add("onclick", "window.close();");
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
trigger example
create trigger t1 on ex
after insert
as
begin
print 'values inserted'
end
creating a view
create view v1 as select * from ex


list box example
if (!IsPostBack)
{

ArrayList values = new ArrayList();

values.Add ("IN");
values.Add ("KS");
values.Add ("MD");
values.Add ("MI");
values.Add ("OR");
values.Add ("TN");

ListBox1.DataSource = values;
ListBox1.DataBind();
}

1.. We have three types of session mode.

1.Inproc:
2.OutProc:
3.SQLServer

InProc: - In this mode Session, state is stored in the memory space of the
Aspnet_wp.exe process. This is the default setting. If the IIS reboots or web application
restarts then session state is lost.
StateServer:-In this mode Session state is serialized and stored in a separate process
(Aspnet_state.exe); therefore, the state can be stored on a separate computer(a state
server).
SQL SERVER: - In this mode Session, state is serialized and stored in a SQL Server
database.
Session state can be specified in element of application configuration file. Using
State Server and SQL SERVER session state can be shared across web farms but note this comes
at speed cost as ASP.NET needs to serialize and deserialize data over network repeatedly.

Notice the "@ Register" directive . This registers the control on the page. Once the control is registered on the page,
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
To use the IDE project properties to generate a key pair and sign your assembly, follow these steps:
a. In Solution Explorer, right-click GACDemo(project), and then click Properties.
b. Click the Signing tab, and then click to select the Sign the assembly check box.
c. In the Choose a strong name key list, click .
d. Type GACkey.snk as the key file name, click to clear the Protect my key file with a password check box, and then click OK.
e. Press CTRL+SHIFT+B to compile the project.
=============================================================================for creating a .dll file to website we have to publish website


SQL SPLITTING VALUE INTO 2 VALUES
Q:
i,
how to get the no after ~ symbol



100 P1~10
101 P12~20
102 P334~30
103 P90~333
ANS
string str="100 P1~10";
string[] arrstr=str.split('~');

string Value1=arrstr[0];
string Value2=arrstr[1];

example:
row = ds.Tables[0].NewRow();
row[0] = textBox1.Text;
string abc = textBox2.Text;
string[] list = abc.Split(',');
string Value1 = list[0];
string Value2 = list[1];
row[1] = Value1;
row[2] = Value2;
ds.Tables[0].Rows.Add(row);
da.Fill(ds, "ex");

da.Update(ds.Tables[0]);


working with time and date controls

here is a example for date and time using console application

namespace date_and_time
{
class Program
{
static void Main(string[] args)
{
DateTime CurrTime = DateTime.Now;

Console.WriteLine("d: {0:d}", CurrTime);
Console.WriteLine("D: {0:D}", CurrTime);
Console.WriteLine("f: {0:f}", CurrTime);
Console.WriteLine("F: {0:F}", CurrTime);
Console.WriteLine("g: {0:g}", CurrTime);
Console.WriteLine("G: {0:G}", CurrTime);
Console.WriteLine("m: {0:m}", CurrTime);
Console.WriteLine("M: {0:M}", CurrTime);
Console.WriteLine("r: {0:r}", CurrTime);
Console.WriteLine("R: {0:R}", CurrTime);
Console.WriteLine("s: {0:s}", CurrTime);

Console.WriteLine("t: {0:t}", CurrTime);
Console.WriteLine("T: {0:T}", CurrTime);
Console.WriteLine("u: {0:u}", CurrTime);
Console.WriteLine("U: {0:U}", CurrTime);
Console.WriteLine("y: {0:y}", CurrTime);
Console.WriteLine("Y: {0:Y}", CurrTime);

}
}
}

out put

d: 5/6/2002
D: Sunday, May 06, 2002
f: Sunday, May 06, 2002 1:06 PM
F: Sunday, May 06, 2002 1:06:51 PM
g: 5/6/2002 1:06 PM
G: 5/6/2002 1:06:51 PM
m: May 06
M: May 06
r: Sun, 06 May 2002 13:06:51 GMT
R: Sun, 06 May 2002 13:06:51 GMT
s: 2002-05-06T13:06:51
t: 1:06 PM
T: 1:06:51 PM
u: 2002-05-06 13:06:51Z
U: Sunday, May 06, 2002 6:06:51 PM
y: May, 2002
Y: May, 2002


====================================================================================

Coneting to mysql from datagrid

using System.Data.Odbc;


OdbcConnection myConnection = new OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};User ID=root;Password=datta;Database=appaji;Server=localhost");

myConnection.Open();
OdbcDataAdapter da = new OdbcDataAdapter("select * from generalcorespond", myConnection);
DataSet ds1 = new DataSet();
da.Fill(ds1, "generalcorespond");

GridView1.DataSource = ds1;
GridView1.DataBind();
myConnection.Close();


===============================================================================

adding a table dynamicaly
//this.Controls.Add(new LiteralControl(""));
//this.Controls.Add(new LiteralControl(""));
//this.Controls.Add(new LiteralControl(""));
//this.Controls.Add(new LiteralControl(""));
//this.Controls.Add(new LiteralControl("
hi
raja
sekhar
"));

No comments: