I am getting below Error
“Update requires a valid InsertCommand when passed DataRow collection with new rows.”
Below is the code in Module
Module ModDBConnection
Public CnCommon As New SqlConnection
Public DTCodeMaster As New DataTable
Public DACodeMaster As New SqlDataAdapter
Public CBCodeMaster As New SqlCommandBuilder
Public Sub CommonCn()
CnCommon = New SqlConnection
CnCommon.ConnectionString = "Data Source=DELTA\SQL_PRAVIN;Initial CatAlog=PAYDATANET;User ID=accounts;Password=accounts"
CnCommon.Open()
End Sub
Public Sub RSCodeMaster()
Call CommonCn()
Dim Sas As String = "SELECT * FROM Tbl_AccountMaster "
Dim DACodeMaster = New SqlClient.SqlDataAdapter(Sas, CnCommon)
Dim CBCodeMaster = New SqlClient.SqlCommandBuilder(DACodeMaster)
DACodeMaster.Fill(DTCodeMaster)
End Sub
End Module
Below code is on my form
Call RSCodeMaster()
Dim RowNo As Integer
Dim adnewrow As DataRow = DTCodeMaster.NewRow()
DTCodeMaster.Rows.Add(adnewrow)
RowNo = DTCodeMaster.Rows.Count - 1
adnewrow("Acct_Code") = TxtAcctCode.Text
DACodeMaster.Update(DTCodeMaster) ' Errow on this line
What could be the issue?
Thanks