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. General Programming
  3. Visual Basic
  4. problem while trying to insert number of rows into the database using dataset and tablemapping

problem while trying to insert number of rows into the database using dataset and tablemapping

Scheduled Pinned Locked Moved Visual Basic
helpdatabaseannouncement
1 Posts 1 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.
  • K Offline
    K Offline
    kisran
    wrote on last edited by
    #1

    hello frends ....... m facing problem while trying to insert values into the database using dataset and tablemapping...... getting error no coloumn at index 0

    Dim ds As New DataSet
    ds.Tables.Add("DATA")
    Dim dr As System.Data.DataRow
    Dim k As Integer
    ' For i = 1 To 90
    Dim m As Integer
    ' m = i
    m = 1
    k = 0
    ' Dim t As TextBox = Panel2.FindControl("Text" & i.ToString())
    ' If t.Visible = True Then
    dr = ds.Tables("DATA").NewRow()
    dr(k) = Session("proj")
    k = k + 1
    dr(k) = Session("vol_name")
    k = k + 1
    dr(k) = Session("brd")
    k = k + 1
    For j = 1 To 9
    If j = 4 Then
    Dim d1 As DropDownList = Panel2.FindControl("Text" & m.ToString())
    m = m + 1
    dr(k) = d1.SelectedValue
    k = k + 1
    Else
    Dim t1 As TextBox = Panel2.FindControl("Text" & m.ToString())
    m = m + 1
    If t1.Text.Trim() = "" Then
    dr(k) = OracleString.Null
    k = k + 1
    Else
    dr(k) = t1.Text.Trim()
    k = k + 1
    End If
    End If
    Next
    ds.Tables("DATA").Rows.Add(dr)
    ' Else
    ' Exit For
    ' End If
    ' i = i + 8
    ' Next
    '*******************************
    Dim cn As OracleConnection
    cn = New OracleConnection("user id=lntforms;data source=;password=user123")
    cn.Open()
    Dim sq1 As String
    sq1 = "SELECT * FROM CMS_LOADLIST"
    Dim oraDa As OracleDataAdapter
    oraDa = New OracleDataAdapter(sq1, cn)
    oraDa.TableMappings.Add("Load_list", "DATA")
    oraDa.Fill(ds, "CMS_LOADLIST")
    'Label5.Text = ds.Tables("DATA").Columns.Count.ToString()
    Dim cb As OracleCommandBuilder
    oraDa.SelectCommand = New OracleCommand(sq1, cn)
    cb = New OracleCommandBuilder(oraDa)
    Try
    oraDa.Update(ds, "DATA")
    ds.AcceptChanges()
    'Session.Add("ds", this.ds)
    Catch ex As System.Exception
    'err = 1
    ds.RejectChanges()
    'Session.Add("ds", this.ds)
    If ex.Message.StartsWith("ORA-00001") Then
    Label5.BackColor = Color.Red
    Label5.Text = "All project entries must be unique."
    Else
    Label5.BackColor = Color.Red
    Label5.Text = ex.Message()
    End If
    End Try

    please help me out....

    kisran

    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