Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 9188 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > C# > insert directly from application to database ...
Sabarimahesh

insert directly from application to database

 Code Snippet posted by: Sabarimahesh | Posted on: 6/14/2012 | Category: C# Codes | Views: 3199 | Status: [Member] | Points: 40 | Alert Moderator   
Ads

string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

try
{
using (SqlConnection connect = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand();
command.Connection = connect;
command.CommandText = "insert into customer(name, address) values(@name, @address)";
command.Parameters.Add(new SqlParameter("@name", SqlDbType.VarChar));
command.Parameters.Add(new SqlParameter("@address", SqlDbType.VarChar));
command.Parameters["@name"].Value = name.Text.ToLower();
command.Parameters["@address"].Value = address.Text.ToLower();
connect.Open();
}
}


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/18/2013 12:59:10 AM