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
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Error in inserting records in SQL Server
Venkatesan Jayakantham
Jun 13, 2010
3.7
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
Error in inserting records in SQL Server
I got a message from one of the forum member in this site and I would like to provide some suggestions on the same.
-------------------------------------------------------------------------------------------------
Hello Sir.....I have some problem on SQL Server database and want to ask u as
I am facing the error:
{"Cannot insert the value NULL into column 'name', table 'C:\\DOCUMENTS AND SETTINGS\\ADMINISTRATOR\\DESKTOP\\ARTICLE 17\\SIMPLE LOGIN PROJECT IN ASP.NET\\APP_DATA\\MYDB.MDF.dbo.myTb'; column does not allow nulls. INSERT fails.\r\nThe statement has been terminated."}
I have following MSSQL server database
*************************************
id int Unchecked
name varchar(100) Unchecked
username varchar(100) Unchecked
password varchar(100) Unchecked
emailid varchar(100) Unchecked
I am following code in Default.aspx page
*******************************************
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myDbConnectionString1 %>"
InsertCommand="INSERT INTO myTb(name, username, password, emailid) VALUES (@name, @username, @password, @emailid)" SelectCommand="SELECT myTb.* FROM myTb">
============================================================
This above error clearly specifies that, there is an issue with "name" column. We need to check the insert statement at this stage. Because, the name column is not null.
The above issue is due to the @name value passed in the insert statement.
Cheers,
Venkatesan Prabu .J
http://venkattechnicalblog.blogspot.com/
Error in inserting records in SQL Server
Next Recommended Reading
CImageHelper::Init () Failed load of dbghelp.dll - SQL Server error