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!

System.Reflection.AmbiguousMatchException

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
Here's the error code, what does it mean? (technology...)
Code:
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\[URL unfurl="true"]wwwroot2\secure\seniors.aspx:line[/URL] 75

From this line:
objAdapt.Update(objRow(0))

Here's where I create my Update command... what do I do?
objAdapt.UpdateCommand = new oledbcommand("UPDATE tblNewOrderNum SET wOrder = wOrder + 1", objConn)
 
I'm sorry if I'm boring, frustrated, or stupid. I totally gave up on that chunk of code since I can't find the answer, and nobody else seems to be able to help... So I changed it to something else. Once again, all I want to do, is read a record/field, increment that number, then upload that new name back to the database. Here's the new code:
Code:
Function newWebNum As String
     Dim strSql As String = "SELECT * FROM tblNewOrderNum"
     Dim objConn As New OledbConnection(Application("dbAccess"))
     Dim objComm As New OleDbCommand(strSql, objConn)
     Dim objRead As OledbDataReader
     Dim rowNum, yNum, strNewNumI, strNewNum As String
     
     objConn.Open()
     
     try
      objRead = objComm.ExecuteReader()
      Do While objRead.Read()
       strNewNum = objRead("wOrders")
      Loop
     catch ex As Exception
      Msg.Text = ex.ToString
     finally
      objRead.Close()
     end try
     
     strNewNumI = strNewNum + 1

     strSql  = "UPDATE tblNewOrderNum SET wOrders = '" & strNewNumI & "'"
     Dim objCmd as New OLEDBCommand(strSQL, objConn)
     Try
objCmd.ExecuteNonQuery()
Code:
      Msg2.Text = strSQL
     Catch ex As Exception
      Msg.Text = ex.ToString
      Msg2.Text = strSQL
     End Try
     objConn.Close
     Return strNewNum
    End Function

Which gives me this error:
System.Data.OleDb.OleDbException: Operation must use an updateable query. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at ASP.seniors_aspx.newWebNum() in C:\Inetpub\ 84

BTW, this is the string it's trying to use:
UPDATE tblNewOrderNum SET wOrders = '16505'
 
FYI: It finally works... I had no understanding of what parameters were and by blindly trying posted examples was unable to understand this until somebody showed me the light. Perhaps I will work on an FAQ for others like me.

This is what I ended up with:

Code:
    Function newWebNum As String
     Dim strReq As String = "SELECT * FROM tblNewOrderNum" 
     Dim objData AS New DataSet() 
     Dim objConn As New OledbConnection(Application("dbAccess")) 
     Dim objAdapt As New OleDbDataAdapter(strReq, objConn) 
     Dim objTable As DataTable 
     Dim objRow As DataRow 
     Dim strNewNumI, strNewNum As String 
     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 wOrders = ? ", objConn)
      objAdapt.Updatecommand.Parameters.Add("@wOrder", system.data.oledb.OleDbType.VarWChar, 15).Value = strNewNumI 
      objAdapt.Updatecommand.parameters("@wOrder").sourcecolumn="wOrders"
      'objAdapt.Update(objTable.Select(Nothing, Nothing, DataViewRowState.ModifiedCurrent))
      objAdapt.Update(objData, "NewOrders") 
     Catch ex As Exception 
      Msg.Text = ex.ToString 
     End Try 
     Return strNewNum
    End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top