Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble Updating Access DataField

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
K, I get my data... change the value I want... then I am trying this:
Code:
objRow("wOrders") = strNewNumI
 'objAdapt.UpdateCommand.CommandText = "UPDATE tblNewOrderNum SET wOrder = '" & strNewNumI & "'"
 'objAdapt.UpdateCommand.Connection = objAdapt.SelectCommand.Connection
 objAdapt.Update(objRow(0), "NewOrders")

(I commented out where I tried to create the UpdateCommand, cause that didn't work.)

I just want to update that one stinking field. Any ideas?
 
I get this message:
System.InvalidCastException: Specified cast is not valid.

On my
Code:
objAdapt.Update
line.
 
The particular overload you are trying to use there expects a dataTableMapping as the second argument, which is where it's puking, since casting a string to a dataTableMapping doesn't fly.

There is an overload of that function that expects simply a datarow, though, so try just cashing your second argument there and see how that works for you.
penny1.gif
penny1.gif
 
Nada... Tried it two ways.
Here is where I update/change the date:
Code:
objAdapt.Fill(objData, "NewOrders")
 objTable = objData.Tables("NewOrders")
 objRow = objTable.Rows(0)
 strNewNum = objRow("wOrders")
 strNewNumI = strNewNum + 1
 objRow("wOrders") = strNewNumI
From this:
Code:
objAdapt.Update(objRow(0))
I get:
System.Reflection.AmbiguousMatchException: No accessible overloaded 'OleDbDataAdapter.Update' can be called without a narrowing conversion. at Microsoft.VisualBasic.CompilerServices.VBBinder.set_InternalThrow(Exception Value) at Microsoft.VisualBasic.CompilerServices.VBBinder.BindToMethod(BindingFlags bindingAttr, MethodBase[] match, Object[]& args, ParameterModifier[] modifiers, CultureInfo culture, String[] names, Object& ObjState) at Microsoft.VisualBasic.CompilerServices.VBBinder.InvokeMember(String name, BindingFlags invokeAttr, Type objType, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn) at Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack) at ASP.seniors_aspx.newWebNum() in C:\Inetpub\ 76


From this:
Code:
objAdapt.Update(objTable))
I get:
System.InvalidOperationException: Update requires a valid UpdateCommand when passed DataRow collection with modified rows. at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) at System.Data.Common.DbDataAdapter.Update(DataTable dataTable) at ASP.seniors_aspx.newWebNum() in C:\Inetpub\ 76
 
I have gone to MSDN, and see where it talks about the different 'overloads' but must admit... I get totally lost.
 
Still having trouble. Trying to recycle what seems to be a dead thread. I know you guys can help me. I wanna read a field, increment that field, and then write the new value back to that same field, on an UNINDEXED record. Here is my current try. (All objects are declared earlier)

Code:
     objAdapt.Fill(objData, "NewOrders")
     objTable = objData.Tables("NewOrders")
     objRow = objTable.Rows(0)
     strNewNum = objRow("wOrders")
     strNewNumI = strNewNum + 1
     objRow("wOrders") = strNewNumI
     Try
      objAdapt.UpdateCommand = new oledbcommand("UPDATE tblNewOrderNum SET wOrder = @wOrder", objConn)
      objAdapt.Update(objData, "NewOrders")
     Catch ex As Exception
      Msg.Text = ex.ToString
     End Try
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top