You probably don't need to set these variables to Nothing - VB does it for you, anyway. And INSERT statement returns no values: Set rstRecordSet = cmdCommand.Execute It is the order in the INSERT statement that matters.Prepared = Trueĭon't use a return value in use the following line. Note that the actual parameter names, e.g. Replace them with the correct field names.CommandText = "INSERT INTO laptopLoggedInLoggedOutInfo(f1,f2,f3,f4,f5,f6,f7) VALUES (?,?,?,?,?,?,?) " RstRecordSet.Open "SELECT MAX(logInId) FROM laptopLoggedInLoggedOutInfo", conConnection logInId = IIf(IsNull(rstRecordSet.Fields(0)), 0, IsNull(rstRecordSet.Fields(0))) With cmdCommandĪre these really your fieldnames: f1, f2, f2, etc.? I would be surprised. My suggestion: use "SELECT MAX(f1) FROM laptopLoggedInLoggedOutInfo", and retrieve the first value, ensuring that if the value is null, it returns zero, e.g. rstRecordSet.Open "laptopLoggedInLoggedOutInfo", conConnection Generally, if you want a unique ID, you must ensure that the ID always increments. If you delete records from the table, then your ID will become smaller. I see that you are using a recordset just to receive a count of records in logInId. conConnection.ConnectionString = "Provider=.12.0 Data Source="
0 Comments
Leave a Reply. |