473,804 Members | 2,140 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

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_kar yawan'; 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 2689
jimatqsi
1,277 Recognized Expert Top Contributor
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
2240
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 into another table ExternalReference which has various foreign keys. This is simple but one of these keys says that the value in ExternalReference.CompanyRef must be in the CompanyReference table. Of course if this is an initial import then it...
1
2583
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" on Access could not create the sequence number as soon as the value has been inserted. The sequence number can only be created after we go to the second line. Please see the trigger below. Is there anyway we could create a trigger that could...
4
10252
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 @@Identity"; // the auto-number fiels int iId = (int)myCommand.ExecuteScalar();
3
7514
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 get the following message: "Cannot insert the value NULL into column 'hdtID', table 'myinstance.mydb.Hotel_Details_Lang'; column does not allow nulls. INSERT fails." Any idea? PS: To create the DataAdapters, I'm using SqlCommandBuilder.
5
2487
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 primary key in the "suspended_table" is an auto incremented integer where as "live_table" primary key is just a standard integer. Here's the life-cycle: 1. Record gets entered into "suspended_table" 2. Record checked and then inserted into...
0
2092
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 inserting a NULL value. Oddly sometimes it works but I don't know why. Can anyone suggest anything else I can try? Perhaps this is the wrong group I'm posting to - it was just the one that came up with other errors giving the same message, but none of...
2
1218
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 2005\WEBSITES\WEBSITE1\APP_DATA\DB.MDF.dbo.users'; column does not allow nulls. INSERT fails. The statement has been terminated." after debugging it. protected void btnAdd_Click(object sender, EventArgs e) { SqlConnection MyConnection; SqlCommand MyCommand;
1
3769
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) but it shows warning that customer can't append all the records in the append query. Customer set 1 field(s) to Null due to a type conersion failure,and it didn't add 0 record(s) to the table due to key violation, 0 record(s) due to lock...
6
1830
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. UPDATE fails. The statement has been terminated. What I am trying to insert is a string that I convert into an int
1
10999
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. Could some one help me?
0
10603
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10353
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9176
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4314
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 we have to send another system
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.