Friday, 15 August 2014

insert and update in vb.net with access index out of range -


I have an application I want to do it 1 - Enter the details first 2 - Receive invoice 3 (maximum) - with ID Enter the details of the invoice, it gives me this error index out of range.

  Enter private entries () as the date of the invoice date as dated date = Today the integer in the form of DIDIID ID as an integral slow client, as a low note string if the clients.Visible = true Then user id = 1 client = 2 note = "cache" other userid = 2 client = 6 note = "credit" and dim query 1 as "string" = "insert in invoice" ([purchased], client, [note] , User id, total, disk) value ('' & amp; cite (invoiceday) & amp; "',' & amp; Clientid & amp; amp; ", & quot; & amp; note & amp; & quot;, & quot;, & amp; userid & amp;; & quot ;, & quot; totalprice.Text & amp; & quot; & quot; & quot; & quot; & quot; & quot; & amp; ; Txtdis.Text & amp; "')" Each line contains DatasearchViewRow as dvsale.Rows dim query string = "as inserting samselect2 (QUERY1) for dim maxinvoice integer maxinvoice = invoiceid ()' '; Maxinvoice + 1 & amp; & Amp; "'invoicede (invoiceid, barcode, doaname, quantity, value, qtyprice) value in (& quot; & quot; row & quot; row & quot; row & quot; row & quot; row (" barcode " Price ("denum"). Price & amp; "'," "& Amp; line Seals (" Quantity "). Value &"', "" & Amp; line Seals ("Value") Value & amp; "," & # 39; Amp; line Seals ("Tacti"). Value & amp; ";)" Samselect2 (Query) Next End Sub  

This samselect2 < / P>

  class of public sub-samselect2 (byVal SQL string) attempt to thief. Open () cmd .Connection = thief .CommandText = SQL pre-capture exceptions (ex.Message, MsgBoxStyle.Exclamation) as the MsgBox con.Close (try) da.Dispose () End Sub  
and the maximum number of invoiceid

  private function invoiceid () checkConnection () in the form of a slow strQ string = "MaxInvoice" OleDbCommand as the slow cmdQ = new OleDbCommand (Strq, con) dim result = cmdQ.ExecuteScalar () If there is no result, then anything as integer = dvd = 0 returns x or returned The final function  

on the end of the result, however I can not fully understand your question I am looking for a few things: 1) It appears that invoiceID is not an automatic incremental identification area, and it should probably be. (See "Identity".) If this happens, you can enter all the fields except one and specify, and the number will automatically increment 2) for you ... in each, you through each loop With maximum repetition max max increase. Although you are using Max-Vice + 1, this will be the same number every time.

However, if you make an invoice ID an identity field, then everyone should be unnecessary.


No comments:

Post a Comment