C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




ASP.Net Record Insertion into table - Problem


Posted Date: 29 Aug 2008      Total Responses: 1

Posted By: Sankararaman       Member Level: Silver     Points: 1


Hello Friends

I am trying to insert a record into the table: I have written the backend procedure which is working fine. I use only 2 controls and a Insert button.

I have customer ID and Customer name to insert: I have copied and pasted my source code. I have button INSERT. On click of that Button I want to insert.

When I run my program - DBfill procedure is not executed. Please let me know how to call this procedure? to insert value on CLICK on INSERT BUTTON

2) How can write this to Update if I have another button as UPDATE

Please help

My advance thanks


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;


public partial class _Default : System.Web.UI.Page

{
public void DbFill()
{

SqlConnection Conn = new SqlConnection(ConfigurationSettings.AppSettings["Buy4nowConnectionString"].ToString());
Conn.Open();

SqlCommand _cmd = new SqlCommand("InsertCustomer", Conn);

_cmd.CommandType = CommandType.StoredProcedure;
_cmd.Parameters.Add(new SqlParameter("@CustId",strCustID.Text));
_cmd.Parameters.Add(new SqlParameter("@customerName",StrCustName.Text));

SqlDataReader _reader = _cmd.ExecuteReader();

Conn.Close();

}

protected void Page_Load(object sender, EventArgs e)
{


}
protected void btnInsert_Click(object sender, EventArgs e)
{

}
}






Responses

Author: Vijaya saradhi    29 Aug 2008Member Level: SilverRating:     Points: 3
Hello friend to perform data manipulation operations like insert,update and delete we need to call command object's ExecuteNonquery() method instead of ExecuteReader() method.I think you got my point.


Post Reply
You must Sign In to post a response.
Next : Interview Question
Previous : Accept changes not working in dataset
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

SPOC

Contact Us    Privacy Policy    Terms Of Use