3 Replies - 1166 Views - Last Post: 23 August 2013 - 05:31 AM Rate Topic: -----

#1 cbu007zn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 20-August 13

i am getting error "There is no row at position 0" from code b

Posted 23 August 2013 - 05:03 AM

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If txtID.Text = "" Then
            MsgBox("Please input a valid Employee code to load a corresponding record", MsgBoxStyle.Information)
        Else
            dbProvider = "Provider=Microsoft.Ace.OLEDB.12.0;"
            dbSource = "Data Source = C:\Users\Blessing\Documents\IBCARIP.accdb;Persist Security Info=False"
            con.ConnectionString = dbProvider & dbSource
            con.Open()
            sql = "select * from Calculator where " _
                & "EmpCode = " & " '" & txtID.Text & "'"

            da = New OleDb.OleDbDataAdapter(sql, con)
            da.Fill(ds, "IBCARIP")
            lblSAI.Text = ds.Tables("IBCARIP").Rows(inc).Item("SName") & ds.Tables("IBCARIP").Rows(inc).Item("FName")
            lblRate.Text = ds.Tables("IBCARIP").Rows(inc).Item("NRate")
            lblOT.Text = ds.Tables("IBCARIP").Rows(inc).Item("OTRate")
            lblBnk.Text = ds.Tables("IBCARIP").Rows(inc).Item("BName") & ".." & ds.Tables("IBCARIP").Rows(inc).Item("ANumber") & ".." & ds.Tables("IBCARIP").Rows(inc).Item("AType")
            con.Close()
            ds.Tables("IBCARIP").DataSet.Clear()
            MaxRows = ds.Tables("IBCARIP").Rows.Count
            'inc = 0
        End If
    End Sub


The error comes when i enter an invalid employee code into txtID.text

This post has been edited by JackOfAllTrades: 23 August 2013 - 05:09 AM
Reason for edit:: Added code tags


Is This A Good Question/Topic? 0
  • +

Replies To: i am getting error "There is no row at position 0" from code b

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6052
  • View blog
  • Posts: 23,487
  • Joined: 23-August 08

Re: i am getting error "There is no row at position 0" from code b

Posted 23 August 2013 - 05:10 AM

You were told before to use code tags. Not only that, it's written all over the site! Please obey the rules!

Here's how you use them:
:code:
Was This Post Helpful? 0
  • +
  • -

#3 ybadragon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 193
  • View blog
  • Posts: 1,183
  • Joined: 11-May 12

Re: i am getting error "There is no row at position 0" from code b

Posted 23 August 2013 - 05:12 AM

On what line does the error occur?
Was This Post Helpful? 0
  • +
  • -

#4 torind_2000  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 57
  • View blog
  • Posts: 288
  • Joined: 22-August 11

Re: i am getting error "There is no row at position 0" from code b

Posted 23 August 2013 - 05:31 AM

select * pulls all records up. Do you really need everything?

Probably should drill down into your SQL statement some and really only ask for what you need in a particular instance.
select EmpId, Fname, Lname, PayRate, OTRate from Employee where EmpId = & txtId.Text

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1