[RESOLVED] Having Problem with the INSERT syntax in VB6...
Hi guys!
:D
I'm having a problem in the INSERT SYNTAX.
I'm currently using MS ACCESS 2007 temporarily because my installer of SQL Server got broken. In my database, I have an "IDNo" set as auto increment so every time I insert a new record it will automatically have a number.
But the problem is that normally in SQL Server you won't require to add the indicated field with an auto increment and if you use a MS ACCESS 2007 as a database, there will be an error in the syntax saying that the number of query values and destination fields are not the same.
Code:
For x = 1 To lvSubject.ListItems.Count
Set rs = New ADODB.Recordset
rs.Open "INSERT INTO tblStudinfo VALUES('" & txtStudNo.Text & "', '" & txtFirstName.Text & "', '" & txtMI.Text & "', '" & txtlastName.Text & "', '" & cboGender.Text & "', '" & lvSubject.ListItems.Item(x) & "')", cnx, adOpenKeyset, adLockPessimistic
Next
....before the txtStudNo there is a field named "IDNo" with an auto increment.
Plz help.. ASAP
tnx!
:wave:
Re: Having Problem with the INSERT syntax in VB6...
If you explicitely include list of fields your problem will go away regardless of any db:
insert into (f1, f2, f3) values (v1, v2, v3)
List of fields can be in any order, however as long as list corresponding values are in the same order it should be alright.
Re: Having Problem with the INSERT syntax in VB6...
Ahh... I see..Thank you RhinoBull.
:D