TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
aditya immadi
NA
205
71.6k
error Cannot insert the value NULL into column 'id', table
Aug 1 2013 6:43 AM
Cannot insert the value NULL into column 'id', table
i got the Above error after i alter the table with id column...i m little bit confused can any one rectifie this..
my .cs code is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
namespace ApComapaign
{
public partial class admim_newuser : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btninsert_Click(object sender, EventArgs e)
{
string filename = Path.GetFileName(FileUploadC.PostedFile.FileName);
filename = txtnameC.Text + "_" + filename;
FileUploadC.SaveAs(Server.MapPath("~/Images-candidates/" + filename));
string constring = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(constring);
cmd.Connection = conn;
conn.Open();
cmd.CommandText = "[SP_Candidate]";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("name", txtnameC.Text);
cmd.Parameters.AddWithValue("image", filename);
cmd.Parameters.AddWithValue("role", ddlCRole.Text);
cmd.Parameters.AddWithValue("party", ddlCparty.Text);
cmd.Parameters.AddWithValue("area", txtarea.Text);
cmd.Parameters.AddWithValue("district", txtdis.Text);
cmd.Parameters.AddWithValue("fb", txtfb.Text);
cmd.Parameters.AddWithValue("blog", txtblog.Text);
cmd.Parameters.AddWithValue("twitter", txttwitt.Text);
cmd.Parameters.AddWithValue("wiki", txtwiki.Text);
cmd.Parameters.AddWithValue("web", txtweb.Text);
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = cmd;
da.Fill(ds);
cmd.ExecuteNonQuery();
conn.Close();
}
}
}
thanks and regards
Reply
Answers (
18
)
i really need help ..., about normalization
Retrieve data from database using ComboBox to GridView