4 Replies - 901 Views - Last Post: 05 September 2012 - 11:50 PM Rate Topic: -----

#1 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

error in insertion

Posted 05 September 2012 - 11:17 PM

hi,
i have created a table,,, now when i am inserting data i got the error,,,i need help
 this is the error
Cannot insert the value NULL into column 'emp_key', table 'TxTdata.dbo.login'; column does not allow nulls. INSERT fails.


Is This A Good Question/Topic? 0
  • +

Replies To: error in insertion

#2 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: error in insertion

Posted 05 September 2012 - 11:21 PM

The column emp_key doesn't accept NULL values. You have to either set Allow Null for the field from the SQL Server(assuming that's your DBMS) or pass a value to it.
Was This Post Helpful? 2
  • +
  • -

#3 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: error in insertion

Posted 05 September 2012 - 11:30 PM

thanks for your quick reply,,,,

that works for me,,,
but i want to know if there is a way that it will automatically assign a unique key value to each entry (id entered),coz i dont want the emp_key to be null .
Was This Post Helpful? 0
  • +
  • -

#4 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: error in insertion

Posted 05 September 2012 - 11:41 PM

If you're using SQL Server you can set the Is Identity column property to Yes and it will increment by 1 per each record hence giving it a unique value.

Posted Image

Or write a function in your code to generate a unique key and pass it along when the insert query.
Was This Post Helpful? 1
  • +
  • -

#5 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: error in insertion

Posted 05 September 2012 - 11:50 PM

thank you,,,:bigsmile:


you know, thats what i was missing,,,:bananaman: actually i'm a novice in [vb.net/sql]

if u could give me some advice how could i be better at this,,,thanks again

with regards :
kai venn
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1