Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. System.IndexOutOfRangeException: There is no row at position 0

System.IndexOutOfRangeException: There is no row at position 0

Scheduled Pinned Locked Moved ASP.NET
helpquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sophia Rekhi
    wrote on last edited by
    #1

    Hi all, i try to put one image in a table. right now the table is empty.i insert image through front end web form by selecting specified image on clicking browse button.after click the insert button then this error is raised. how can i solve this. "System.IndexOutOfRangeException: There is no row at position 0 " pls help me.

    V 1 Reply Last reply
    0
    • S Sophia Rekhi

      Hi all, i try to put one image in a table. right now the table is empty.i insert image through front end web form by selecting specified image on clicking browse button.after click the insert button then this error is raised. how can i solve this. "System.IndexOutOfRangeException: There is no row at position 0 " pls help me.

      V Offline
      V Offline
      Venkatesh Mookkan
      wrote on last edited by
      #2

      Could you please post your code too?? I believe, you are updating the 0th row of the DataSet without adding NewRow to it. As the table is empty, the 0th row does not exists. But this is my assumption. Post your code, lets analyze it...

      Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

      S 1 Reply Last reply
      0
      • V Venkatesh Mookkan

        Could you please post your code too?? I believe, you are updating the 0th row of the DataSet without adding NewRow to it. As the table is empty, the 0th row does not exists. But this is my assumption. Post your code, lets analyze it...

        Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

        S Offline
        S Offline
        Sophia Rekhi
        wrote on last edited by
        #3

        hi venkatesh, you are right, u r assumption is correct. but i want to insert many rows from webform. but this code inserts only one row.if try to insert many rows overwrite and show latest insert record. how to solve this. my code: Dim da As New SqlDataAdapter("Select * From pub_info ", con) Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da) Dim ds As New DataSet da.MissingSchemaAction = MissingSchemaAction.AddWithKey con.Open() da.Fill(ds, "pub_info") Dim fn As String = System.IO.Path.GetFullPath(File1.PostedFile.FileName) Dim fs As New FileStream(fn, FileMode.OpenOrCreate, FileAccess.Read) Dim MyData(fs.Length) As Byte Dim sql As String fs.Read(MyData, 0, fs.Length) fs.Close() ds.Tables("pub_info").Rows(0)("logo") = MyData da.Update(ds, "pub_info") pls help me.

        V 1 Reply Last reply
        0
        • S Sophia Rekhi

          hi venkatesh, you are right, u r assumption is correct. but i want to insert many rows from webform. but this code inserts only one row.if try to insert many rows overwrite and show latest insert record. how to solve this. my code: Dim da As New SqlDataAdapter("Select * From pub_info ", con) Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da) Dim ds As New DataSet da.MissingSchemaAction = MissingSchemaAction.AddWithKey con.Open() da.Fill(ds, "pub_info") Dim fn As String = System.IO.Path.GetFullPath(File1.PostedFile.FileName) Dim fs As New FileStream(fn, FileMode.OpenOrCreate, FileAccess.Read) Dim MyData(fs.Length) As Byte Dim sql As String fs.Read(MyData, 0, fs.Length) fs.Close() ds.Tables("pub_info").Rows(0)("logo") = MyData da.Update(ds, "pub_info") pls help me.

          V Offline
          V Offline
          Venkatesh Mookkan
          wrote on last edited by
          #4

          Sophia Rekhi wrote:

          Dim da As New SqlDataAdapter("Select * From pub_info ", con) Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da) Dim ds As New DataSet da.MissingSchemaAction = MissingSchemaAction.AddWithKey con.Open() da.Fill(ds, "pub_info") Dim fn As String = System.IO.Path.GetFullPath(File1.PostedFile.FileName) Dim fs As New FileStream(fn, FileMode.OpenOrCreate, FileAccess.Read) Dim MyData(fs.Length) As Byte Dim sql As String fs.Read(MyData, 0, fs.Length) fs.Close() ds.Tables("pub_info").Rows(0)("logo") = MyData da.Update(ds, "pub_info")

          Change as below,

          Dim da As New SqlDataAdapter("Select * From pub_info ", con)
          Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
          Dim ds As New DataSet
          
          da.MissingSchemaAction = MissingSchemaAction.AddWithKey
          con.Open()
          da.Fill(ds, "pub_info")
          Dim fn As String = System.IO.Path.GetFullPath(File1.PostedFile.FileName)
          Dim fs As New FileStream(fn, FileMode.OpenOrCreate, FileAccess.Read)
          Dim MyData(fs.Length) As Byte
          Dim sql As String
          fs.Read(MyData, 0, fs.Length)
          fs.Close()
          If ds.Tables("pub_info").Rows.Count=0 Then
              Dim DR As DataRow = ds.Tables("pub_info").NewRow()
              ds.Tables("pub_info").Rows.Add(DR)
          End If
          ds.Tables("pub_info").Rows(0)("logo") = MyData
          da.Update(ds, "pub_info")
          

          I think this would solve your problem.

          Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

          S 1 Reply Last reply
          0
          • V Venkatesh Mookkan

            Sophia Rekhi wrote:

            Dim da As New SqlDataAdapter("Select * From pub_info ", con) Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da) Dim ds As New DataSet da.MissingSchemaAction = MissingSchemaAction.AddWithKey con.Open() da.Fill(ds, "pub_info") Dim fn As String = System.IO.Path.GetFullPath(File1.PostedFile.FileName) Dim fs As New FileStream(fn, FileMode.OpenOrCreate, FileAccess.Read) Dim MyData(fs.Length) As Byte Dim sql As String fs.Read(MyData, 0, fs.Length) fs.Close() ds.Tables("pub_info").Rows(0)("logo") = MyData da.Update(ds, "pub_info")

            Change as below,

            Dim da As New SqlDataAdapter("Select * From pub_info ", con)
            Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
            Dim ds As New DataSet
            
            da.MissingSchemaAction = MissingSchemaAction.AddWithKey
            con.Open()
            da.Fill(ds, "pub_info")
            Dim fn As String = System.IO.Path.GetFullPath(File1.PostedFile.FileName)
            Dim fs As New FileStream(fn, FileMode.OpenOrCreate, FileAccess.Read)
            Dim MyData(fs.Length) As Byte
            Dim sql As String
            fs.Read(MyData, 0, fs.Length)
            fs.Close()
            If ds.Tables("pub_info").Rows.Count=0 Then
                Dim DR As DataRow = ds.Tables("pub_info").NewRow()
                ds.Tables("pub_info").Rows.Add(DR)
            End If
            ds.Tables("pub_info").Rows(0)("logo") = MyData
            da.Update(ds, "pub_info")
            

            I think this would solve your problem.

            Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

            S Offline
            S Offline
            Sophia Rekhi
            wrote on last edited by
            #5

            Thanx venkatesh, it is fine , while i click insert button.but no image is stored in to table.and after clicking the getimage button same error will raise. but your solutions is very helpful to me. thanks

            V 1 Reply Last reply
            0
            • S Sophia Rekhi

              Thanx venkatesh, it is fine , while i click insert button.but no image is stored in to table.and after clicking the getimage button same error will raise. but your solutions is very helpful to me. thanks

              V Offline
              V Offline
              Venkatesh Mookkan
              wrote on last edited by
              #6

              Sophia Rekhi wrote:

              it is fine , while i click insert button.but no image is stored in to table.and after clicking the getimage button same error will raise.

              I don't know how you are implementing this. But I can explain my code, * Selects the record from the table * Checks whether it has record * If no rocord, add a row and update the 0th row * Else just update the 0th row. Its seems you are adding only one image to the table. Why can't your try FileSystem instead of DB?

              Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups