473,387 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Auto number. Cannot insert the value NULL into column 'idNo'

I have been collecting data from ms.access database into a class object

Expand|Select|Wrap|Line Numbers
  1. '_Get and put in data from database Fingerprint(RAS) into CPresensiFingerprint
  2. Public Function GetdbFingerprint() As CPresensiFingerprint
  3. Dim presensiFinger As New CPresensiFingerprint
  4. Dim SQLSelectdbRAS As String
  5. Dim rsFinger As Recordset
  6. Dim dateNow_ As Date
  7.  
  8. dateNow_ = um_TgldanJamSkrg()
  9.  
  10.     SQLSelectdbRAS = "SELECT a.DN, b.DIN, c.PIN, c.UserName, b.Clock, d.ItemName " & _
  11.                      "FROM ((ras_Device a INNER JOIN ras_AttRecord b ON a.DN=b.DN) " & _
  12.                      "LEFT JOIN ras_Users c ON b.DIN=c.DIN) " & _
  13.                      "LEFT JOIN ras_AttTypeItem d ON b.AttTypeId=d.ItemId " & _
  14.                      "WHERE b.DIN=c.DIN AND Format(b.Clock, 'mm/dd/yyyy')=#" & _
  15.                      Format(dateNow_, "mm/dd/yyyy") & "#"
  16.     Debug.Print SQLSelectdbRAS
  17.     Set rsFinger = da_GetRs(SQLSelectdbRAS)
  18.  
  19.     If Not rsFinger.EOF Then
  20.            presensiFinger.device = rsFinger.Fields("DN").Value
  21.            presensiFinger.idFinger = rsFinger.Fields("DIN").Value
  22.            presensiFinger.Nik = rsFinger.Fields("PIN").Value
  23.            presensiFinger.Name = rsFinger.Fields("UserName").Value
  24.            presensiFinger.DateNow = rsFinger.Fields("Clock").Value
  25.            presensiFinger.timeIn = rsFinger.Fields("Clock").Value
  26.            presensiFinger.AbsentType = rsFinger.Fields("ItemName").Value
  27.     End If
  28.  
  29.     rsFinger.Close
  30.     Set rsFinger = Nothing
  31.  
  32.     Set GetdbFingerprint = presensiFinger
  33.  
  34. End Function
  35.  
  36. With name from class module
  37. CPresensiFingerprint
  38.  
  39. Public PVID As Long
  40. Public device As Integer
  41. Public idFinger As Integer
  42. Public DateNow As Date
  43. Public Nik As String
  44. Public Name As String
  45. Public timeIn As Date
  46. Public timeOut As Date
  47. Public AbsentType As String
  48. Public OTHoursNotApproved As Integer
  49.  
  50. I want input the created data from ms.access into sql server 2005 database with class module object
  51.  
  52. '_Input data from CPresensiFingerprint into dbSIKawan (table finger_data_karyawan)
  53. Public Function SavePresensiIn(ByVal presensiSlot As CPresensiFingerprint) As Long
  54.     Dim rsSIKawan As Recordset
  55.     Dim SQLInsertdbSIKawan As String
  56.     Dim SQLSelectdbSIKawan As String
  57.     Dim PVID As Long
  58.  
  59.     Set presensiSlot = New CPresensiFingerprint
  60.  
  61.     SQLInsertdbSIKawan = "INSERT INTO finger_data_karyawan(Device, idFinger, NIKKary, Namakary," & _
  62.                " TglHadir, TimeIn, TipeAbsen)" & _
  63.                " VALUES('" & presensiSlot.device & "', '" & presensiSlot.idFinger & "', '" & _
  64.                presensiSlot.Nik & "', '" & presensiSlot.Name & "', '" & _
  65.                Format(DateValue(presensiSlot.DateNow), "mm/dd/yyyy") & "', '" & _
  66.                Format(presensiSlot.timeIn, "mm/dd/yyyy hh:nn:ss") & "', '" & _
  67.                presensiSlot.AbsentType & "')"
  68.     Call ExeQUERY(SQLInsertdbSIKawan)
  69.  
  70.     SQLSelectdbSIKawan = "SELECT TOP 1 a.idNo FROM finger_data_karyawan a WHERE a.NIKKary='" & _
  71.                          presensiSlot.Nik & "' AND a.TglHadir='" & _
  72.                          Format(DateValue(presensiSlot.DateNow), "mm/dd/yyyy") & "' ORDER BY a.idNo DESC"
  73.     Set rsSIKawan = da_GetRecord(SQLSelectdbSIKawan)
  74.     PVID = rsSIKawan.Fields("idNo").Value
  75.  
  76.     rsSIKawan.Close
  77.     Set rsSIKawan = Nothing
  78.  
  79.     SavePresensiIn = PVID
  80.  
  81. End Function
  82.  
  83. I want the data that has collected in sql server 2005 from class module with auto number, 
  84.  
  85. Private Sub Form_Load()
  86. Dim presensiSlot As CPresensiFingerprint
  87.  
  88. Call SavePresensiIn(presensiSlot)
  89.  
  90. End Sub
but when i running the application. i get error message.

'Cannot insert the value NULL into column 'idNo', table 'dbSIKawan.dbo.finger_data_karyawan'; column does not allow nulls. INSERT fails'

I want the all data insert into sql server database with auto number, so if I want to add other data, the old data is not affected by new data.

Can anyone help me?

Regards,
Octo
Oct 18 '10 #1
1 2672
jimatqsi
1,271 Expert 1GB
An auto-number can never be NULL. I don't see anything in your code that is setting idNo to anything, so if this is all the relevant code I am wondering if the column is defined correctly in the table.

You don't tell very much where this error is occuring, only "when running the application", so I think maybe the error is happening elsewhere, where some code is saying "idNo=" NULL something that is null, or else the column is not really defined to be an auto-number.

Jim
Oct 18 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Chris Gilbert | last post by:
I'm quite stuck with this: I have an import table called ReferenceMatchingImport which contains data that has been sucked from a data submission. The contents of this table have to be imported...
1
by: Ken | last post by:
Need help on the Auto Number or Identity Seed on the Oracle Database I got an Access database that need to be converted to Oracle 9i. Somehow the Trigger we created to simulate the "AUTO NUMBER"...
4
by: Shahar | last post by:
Hi I need to get a field name 'ID'(that is an auto-number field) right after I add a new row to table, it's work like that: myCommand.ExecuteNonQuery(); myCommand.CommandText = "SELECT...
3
by: Fabio Negri Cicotti [MCP] | last post by:
Hi All. I'm trying to insert data into 2 tables (parent-child) using the ADO.NET's SetParentRow method. The parent table has an identity column as primary key. When I execute the code below I...
5
by: Phil Latio | last post by:
I have 2 virtually identical tables and wish to move data between them. Basically one table is called "live_table" and the other is named "suspended_table" and the only difference is that the...
0
by: diane | last post by:
Just trying to upsize using VFP 9 with SQL 2005 using VFP remote views. One in particular keeps coming up and saying Cannot insert the value NULL into column, when I really don't think I am...
2
by: karenkksh | last post by:
Hi, The user_id is set as primary key. "Cannot insert the value NULL into column 'user_id', table 'C:\DOCUMENTS AND SETTINGS\KAREN\MY DOCUMENTS\VISUAL STUDIO...
1
by: billa856 | last post by:
Hi, I am trying to insert Null value in column(ShipDate) in my table.That column(ShipDate)'s type id date/time and format is short date. I am using "" to insert Null in that column(ShipDate)...
6
by: pbd22 | last post by:
Hi. I am trying to insert a zero into the below table and I am being told that: Cannot insert the value NULL into column 'UsageToday', table DB.dbo.Pub_Count'; column does not allow nulls....
1
by: ghjk | last post by:
I'm a new to postgres. i have a table which is having a colomn with auto increment value. When I insert value to that table, it gives an error. First column is the auto increment one....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.