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/
Ebook Download
View all
Learn
View all