--connection
<connectionStrings>
<add name="ConString" connecti onString="Data Source=MUTHU-PC\SQLEXPRESS; Integrated Security=SSPI;Initial Catalog=master" providerName=" System.Data.SqlClient"/>
</connectionStrings>
2.how can we insert data from front end to database will be shown here.basically we have to create connection string object and create new sql connection.after that create object from sqlcommand.that is what we are going to execute.then we should give whatever our query as commandtext.hope you people can manage by looking this.
--insert
string constr = ConfigurationManager. ConnectionStrings["ConString"] .ConnectionString;
SqlConnection necon = new SqlConnection(constr);
necon.Open();
SqlCommand newcmd = necon.CreateCommand();
newcmd.CommandType = CommandType.Text;
newcmd.CommandText = "insert into useraccount values('"+txtname.Text. ToString()+"','"+txtpw.Text. ToString()+"')";
newcmd.ExecuteNonQuery();
necon.Close();
3.here i have done how to search some values which are already in the database.
3.here i have done how to search some values which are already in the database.
--search
string constr = ConfigurationManager. ConnectionStrings["ConString"] .ConnectionString;
SqlConnection newcon = new SqlConnection(constr);
newcon.Open();
SqlCommand newcmd = newcon.CreateCommand();
newcmd.CommandType = CommandType.Text;
newcmd.CommandText = "select uname,pword from useraccount where uname='" + txtname.Text.ToString() + "' and pword='"+txtpw.Text.ToString() +"'";
SqlDataReader da =newcmd.ExecuteReader();
if (da.HasRows)
{
Response.Redirect("Default. aspx");
}
else
{
Response.Redirect("home.aspx") ;
}
newcon.Close();
4.How to fill a drop down list with a dataset can learn from this code.
4.How to fill a drop down list with a dataset can learn from this code.
--data fill drop downlist
string constr=ConfigurationMan ager.ConnectionStrings[" ConString"].ConnectionString;
SqlConnection newcon = new SqlConnection(constr);
newcon.Open();
SqlCommand newcmd = newcon.CreateCommand();
newcmd.CommandType = CommandType.Text;
newcmd.CommandText = "select uname from useraccount";
SqlDataReader da = newcmd.ExecuteReader();
drpuser.DataSource = da;
drpuser.DataValueField = "uname";
drpuser.DataTextField = "uname";
drpuser.DataBind();
5.How to fill a grid view with a dataset can learn from this code.
5.How to fill a grid view with a dataset can learn from this code.
--fill grid
string constr=Configurat ionManager.ConnectionStrings[" ConString"].ConnectionString;
SqlConnection newcon = new SqlConnection(constr);
newcon.Open();
SqlCommand newcmd = newcon.CreateCommand();
newcmd.CommandType = CommandType.Text;
newcmd.CommandText = "select * from useraccount";
SqlDataReader da = newcmd.ExecuteReader();
GridView1.DataSource = da;
GridView1.DataBind();
6.We can decorate our whole application using one css class.by css class we can make our all interfaces consistent.so it is an important class when it comes to asp.net.but we can create sstems without css classes by using manually decorations in properties fields.
6.We can decorate our whole application using one css class.by css class we can make our all interfaces consistent.so it is an important class when it comes to asp.net.but we can create sstems without css classes by using manually decorations in properties fields.
--css class
body
{
background-color:Lime;
}
--html
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
--js class
function myf(x)
{
document.getElementById(x). style.display = 'none';
}
--html
<head>
<script src="myf.js"></script>
</head>
<body>
<input type="button" value="muthu" onclick="myf('GridView1')" />
</body>
No comments:
Post a Comment