A
amessimon
Hi
I have a problem with an insert statment using the update() method of the
OledbDataAdapter.
I'm getting the error 'Update requires a valid InsertCommand when passed
DataRow collection with new rows. '
Heres a condensed version of the page.
<%@ Import Namespace="system.Data" %>
<%@ Import Namespace="system.Data.Oledb" %>
<script language="vb" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim objDataSet As New DataSet()
Dim objDataAdapter As New OledbDataAdapter()
Dim strConnection As String =
ConfigurationSettings.AppSettings("ConnectionString")
Dim strSQL As String = "SELECT [ppcTerm], [pageName], [contentTitle],
[contentBody] FROM tbl_content"
Dim objConnection As New oleDbConnection(strConnection)
Dim objCommand As New oleDbCommand(strSQL, objConnection)
objDataAdapter.SelectCommand = objCommand
objDataAdapter.Fill(objDataSet)
Dim objNewRow As DataRow = objDataSet.Tables(0).NewRow
objNewRow(0) = "value1"
objNewRow(1) = "value2"
objNewRow(2) = "value3"
objNewRow(3) = "value4"
objDataSet.Tables(0).Rows.Add(objNewRow)
objDataAdapter.Update(objDataSet)
End sub
</script>
I'm aware there are other ways of doing this like using an INSERT statement,
but i'd like to know why this isnt working.
Thanks for any help in advance.
Simon Ames
I have a problem with an insert statment using the update() method of the
OledbDataAdapter.
I'm getting the error 'Update requires a valid InsertCommand when passed
DataRow collection with new rows. '
Heres a condensed version of the page.
<%@ Import Namespace="system.Data" %>
<%@ Import Namespace="system.Data.Oledb" %>
<script language="vb" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim objDataSet As New DataSet()
Dim objDataAdapter As New OledbDataAdapter()
Dim strConnection As String =
ConfigurationSettings.AppSettings("ConnectionString")
Dim strSQL As String = "SELECT [ppcTerm], [pageName], [contentTitle],
[contentBody] FROM tbl_content"
Dim objConnection As New oleDbConnection(strConnection)
Dim objCommand As New oleDbCommand(strSQL, objConnection)
objDataAdapter.SelectCommand = objCommand
objDataAdapter.Fill(objDataSet)
Dim objNewRow As DataRow = objDataSet.Tables(0).NewRow
objNewRow(0) = "value1"
objNewRow(1) = "value2"
objNewRow(2) = "value3"
objNewRow(3) = "value4"
objDataSet.Tables(0).Rows.Add(objNewRow)
objDataAdapter.Update(objDataSet)
End sub
</script>
I'm aware there are other ways of doing this like using an INSERT statement,
but i'd like to know why this isnt working.
Thanks for any help in advance.
Simon Ames