dcsimg
Results 1 to 4 of 4

Thread: Record is inserting at improper place in .mdb database with vb6.0

  1. #1

    Thread Starter
    New Member vbdevelopersubi's Avatar
    Join Date
    Aug 2019
    Posts
    1

    Record is inserting at improper place in .mdb database with vb6.0

    I am Subeesh. I have done my accounting project in Vb 6.0
    version with .mdb MS access database. When I insert some records it is not adding at last instead it is adding in between other records. I.e., I entered some records of sales info. After the 19 th record when I try to insert 20 th record, it is adding in between 5th and 6th records.
    Can anyone please tell me the solution.


    Database connection I already given in the form load event it is working properly

    This code I used to insert record is given below. This is only some portion of the code all I cannot paste here

    str = "INSERT INTO daybook(vno, date1, time1, Receiveorpay, FromTo, against, Dr, Cr, rmk) VALUES('" + CStr(no) + "', '" + Format(frmtrans.sinvdate.Value, "dd/mm/yyyy") + "', '" + CStr(Format(frmtrans.sinvdate.Value, "hh:mm:ss AM/PM")) + "', 'Received', '" + frmtrans.cmbctrm.Text + "', 'Sales', '" + frmtrans.lblgt.Caption + "', '0', 'Invoice No. " + frmtrans.lblinvno.Caption + "')"
    ElseIf (Trim(frmtrans.cmbcoc.Text) = "Credit") Then
    dt = frmtrans.sinvdate.Value + Val(Trim(frmtrans.txtcrp.Text))
    str = "INSERT INTO credit(invno, invdt, duedt, Amt, customer, pors) VALUES('" + frmtrans.lblinvno.Caption + "', '" + Format(frmtrans.sinvdate.Value, "dd/mm/yyyy") + "', '" + Format(dt, "dd/mm/yyyy") + "', '" + frmtrans.lblgt.Caption + "', '" + frmtrans.cmbctrm.Text + "', 'Sales')"
    End If
    ' Set rec1 = New ADODB.Recordset
    frmtrans.con.CursorLocation = adUseClient
    Set rec1 = frmtrans.con.Execute(str)
    If (rec1.State <> 0) Then
    MsgBox "Query execution error!, Day book cannot be saved!, Please contact the developer", vbOKOnly, "Eorror"
    functions.SaveErrorMsg App.path + "\shop" + frmtrans.lblsi.Caption + "\err\errmsg.txt", "Query execution error!, Day book about Sales cannot be saved!" + Err.Description + " cmdsv_Click() in frmtrans" + CStr(Now)
    Exit Function
    Else
    End if

  2. #2
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    297

    Re: Record is inserting at improper place in .mdb database with vb6.0

    google "why is access displaying my records out of order"

  3. #3
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,510

    Re: Record is inserting at improper place in .mdb database with vb6.0

    DllHell is in a way correct that the answer can be found on a thousand places.
    Items in a DB are stored in a table in the way the DB engine likes.
    There is no order.
    If you want order you need to ask for order when retrieving the data.

    https://www.w3schools.com/sql/sql_orderby.asp

  4. #4
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    644

    Re: Record is inserting at improper place in .mdb database with vb6.0

    Rule #1 of Relational Databases (and, in this respect, even MS Access counts)

    Rows in Relational Tables have no intrinsic order.

    The database will store rows in any way that it finds convenient.
    The "physical" ordering of rows in any table should not concern you in the slightest.

    The only way to guarantee the order of rows returned is to use the "order by" clause in your select statements.

    Regards, Phill W.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width