Cannot insert data with Datatable
Posted: Mon 17 Dec 2007 14:18
Hi ,
I am trying insert data into database as follows
textbox1.text is one and so on the code used is
The problem is when I execute the above in click event of a button it throws a exception saying Column cust_ac_id does not belong to cust_dtls .
But cust_ac_id is a part of the table.
Note:
dataset11 is filling the datagrid view before being used for entry
I am trying insert data into database as follows
textbox1.text is one and so on the code used is
Code: Select all
try
Dim dt As CoreLab.PostgreSql.PgSqlDataTable
Dim dr As DataRow
dt = DataSet11.Tables(0)
dr = dt.NewRow()
dr("cust_ac_id") = TextBox1.Text.Trim ' new account no
dr("cust_ol_ac_id") = TextBox6.Text.Trim ' old account no
dr("cust_nm") = TextBox2.Text.Trim & TextBox3.Text.Trim ' name this has to be changed later on with seperate first and last name column
dr("cust_mnr_dtls") = TextBox5.Text.Trim
dr("cust_addrs") = TextBox4.Text.Trim
dt.Rows.Add(dr)
Catch ex As Exception
MsgBox("An Error occured please contact administrator" & Chr(13) & " Error Code 003" & Chr(10) & ex.Message, MsgBoxStyle.Critical)
End Try
But cust_ac_id is a part of the table.
Note:
dataset11 is filling the datagrid view before being used for entry