By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,969 Members | 1,735 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,969 IT Pros & Developers. It's quick & easy.

out of range erxception

P: 19
I'm having out of range exception when executing the line
Expand|Select|Wrap|Line Numbers
  1. rdr_mfdby = rdr(" Mfd_company").ToString
  2.  
  3.  
FYI giving the code below.
Expand|Select|Wrap|Line Numbers
  1.  
  2.   Private Sub AllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AllToolStripMenuItem.Click
  3.         Dim todate = DateAndTime.Now.Date
  4.         If con.State = ConnectionState.Closed Then
  5.             con.Open()
  6.         End If
  7.         Dim cmd As OleDbCommand = New OleDbCommand("Select In_date, product_name, Batch_no, pack, Mfd_company from Inward_Entry", con)
  8.         Dim rdr As OleDbDataReader
  9.         rdr = cmd.ExecuteReader
  10.         Dim dt As DataTable = New DataTable
  11.         Try
  12.             Dim span As TimeSpan
  13.             Dim rdr_dt As Date
  14.             Dim rdr_name, rdr_batch, rdr_pack, rdr_mfdby As String
  15.            While rdr.Read()
  16.                 rdr_dt = rdr("in_date").date
  17.                 rdr_name = rdr("Product_name").ToString
  18.                 rdr_batch = rdr("Batch_no").ToString
  19.                 rdr_pack = rdr("pack").ToString
  20.                 rdr_mfdby = rdr(" Mfd_company").ToString
  21.                 span = todate.Subtract(rdr_dt)
  22.                 Dim cmd1 As OleDbCommand = New OleDbCommand("update warehouse_master set ageing = span  where product_name='" & rdr_name & "' and product_batch_no='" & rdr_batch & "' and item_pack='" & rdr_pack & "' and product_manufacturer='" & rdr_mfdby & "' ", con)
  23.                 cmd1.ExecuteNonQuery()
  24.             End While
  25.         Catch ex As Exception
  26.             MessageBox.Show(ex.ToString)
  27.         End Try
  28.         con.Close()
  29.     End Sub
  30.  
Plz help
Dec 27 '10 #1
Share this Question
Share on Google+
2 Replies


P: 46
If it is not a typo here then the leading blank in your indexor will cause this kind of error.

(" Mfd_company") must be ("Mfd_company").
Dec 27 '10 #2

P: 19
I'v done it myself. Bt thanks a lot for your time and support
Dec 28 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.