problem while trying to insert number of rows into the database using dataset and tablemapping
-
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 Tryplease help me out....
kisran