473,507 Members | 5,257 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

'_Get and put in data from database Fingerprint(RAS) into CPresensiFingerprint
Public Function GetdbFingerprint() As CPresensiFingerprint
Dim presensiFinger As New CPresensiFingerprint
Dim SQLSelectdbRAS As String
Dim rsFinger As Recordset
Dim dateNow_ As Date

dateNow_ = um_TgldanJamSkrg()

SQLSelectdbRAS = "SELECT a.DN, b.DIN, c.PIN, c.UserName, b.Clock, d.ItemName " & _
"FROM ((ras_Device a INNER JOIN ras_AttRecord b ON a.DN=b.DN) " & _
"LEFT JOIN ras_Users c ON b.DIN=c.DIN) " & _
"LEFT JOIN ras_AttTypeItem d ON b.AttTypeId=d.ItemId " & _
"WHERE b.DIN=c.DIN AND Format(b.Clock, 'mm/dd/yyyy')=#" & _
Format(dateNow_, "mm/dd/yyyy") & "#"
Debug.Print SQLSelectdbRAS
Set rsFinger = da_GetRs(SQLSelectdbRAS)

If Not rsFinger.EOF Then
presensiFinger.device = rsFinger.Fields("DN").Value
presensiFinger.idFinger = rsFinger.Fields("DIN").Value
presensiFinger.Nik = rsFinger.Fields("PIN").Value
presensiFinger.Name = rsFinger.Fields("UserName").Value
presensiFinger.DateNow = rsFinger.Fields("Clock").Value
presensiFinger.timeIn = rsFinger.Fields("Clock").Value
presensiFinger.AbsentType = rsFinger.Fields("ItemName").Value
End If

rsFinger.Close
Set rsFinger = Nothing

Set GetdbFingerprint = presensiFinger

End Function

With name from class module
CPresensiFingerprint

Public PVID As Long
Public device As Integer
Public idFinger As Integer
Public DateNow As Date
Public Nik As String
Public Name As String
Public timeIn As Date
Public timeOut As Date
Public AbsentType As String
Public OTHoursNotApproved As Integer

I want input the created data from ms.access into sql server 2005 database with class module object

'_Input data from CPresensiFingerprint into dbSIKawan (table finger_data_karyawan)
Public Function SavePresensiIn(ByVal presensiSlot As CPresensiFingerprint) As Long
Dim rsSIKawan As Recordset
Dim SQLInsertdbSIKawan As String
Dim SQLSelectdbSIKawan As String
Dim PVID As Long

Set presensiSlot = New CPresensiFingerprint

SQLInsertdbSIKawan = "INSERT INTO finger_data_karyawan(Device, idFinger, NIKKary, Namakary," & _
" TglHadir, TimeIn, TipeAbsen)" & _
" VALUES('" & presensiSlot.device & "', '" & presensiSlot.idFinger & "', '" & _
presensiSlot.Nik & "', '" & presensiSlot.Name & "', '" & _
Format(DateValue(presensiSlot.DateNow), "mm/dd/yyyy") & "', '" & _
Format(presensiSlot.timeIn, "mm/dd/yyyy hh:nn:ss") & "', '" & _
presensiSlot.AbsentType & "')"
Call ExeQUERY(SQLInsertdbSIKawan)

SQLSelectdbSIKawan = "SELECT TOP 1 a.idNo FROM finger_data_karyawan a WHERE a.NIKKary='" & _
presensiSlot.Nik & "' AND a.TglHadir='" & _
Format(DateValue(presensiSlot.DateNow), "mm/dd/yyyy") & "' ORDER BY a.idNo DESC"
Set rsSIKawan = da_GetRecord(SQLSelectdbSIKawan)
PVID = rsSIKawan.Fields("idNo").Value

rsSIKawan.Close
Set rsSIKawan = Nothing

SavePresensiIn = PVID

End Function

I want the data that has collected in sql server 2005 from class module with auto number,

Private Sub Form_Load()
Dim presensiSlot As CPresensiFingerprint

Call SavePresensiIn(presensiSlot)

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 2134
danp129
323 Recognized Expert Contributor
In SQL Server, an auto numbered column would be an number type field (tinyint/smallint/int/bigint/numeric with no scale) with "Identity" specified.

E.g.
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE [dbo].[myTable] (
  2.     [id] [tinyint] IDENTITY(1,1) NOT NULL,
  3.     [name] [varchar](100) NOT NULL,
  4. )
  5. GO
tinyint will only go up to 255, so choose a data type that works for you.
Oct 18 '10 #2

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

Similar topics

3
2224
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
2560
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
10220
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
7498
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
2472
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
2069
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
1200
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
3744
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
1812
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
10982
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
7221
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
7313
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,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7029
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.