Trying to edit a DataRow

G

Guest

Can anyone tell me why I am getting this error?

Dim dr1 As DataRow = das2.Tables(0).Rows.Find("Baltimore")
dr1("[1]") = ascore

Try
dap2.Update(das2, "teamscores")
Catch
MsgBox(Err.Number)
MsgBox(Err.Description)
End Try

An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format.
 
M

Miha Markic [MVP C#]

Hi Tom,

As Ryan asked - where the exception occurs?
If inside try/catch block then I would say your adapter is not well
configured.
 
M

Miha Markic [MVP C#]

Hi Tom,

Finds searches by primary key thus if your primary key isn't a string or
there is no pk at all you'll get an exception.
Since you are getting FormatException I guess your pk is not a string.
If you want to search by some other column, use DataView or DataTable.Select

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Tom Nowak said:
It is throwing it at the Dim dr1 As DataRow =
das2.Tables(0).Rows.Find("Baltimore") statement.
William Ryan eMVP said:
Is it throwing the exception on the dr1("[1]") line?

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
Tom Nowak said:
Can anyone tell me why I am getting this error?

Dim dr1 As DataRow = das2.Tables(0).Rows.Find("Baltimore")
dr1("[1]") = ascore

Try
dap2.Update(das2, "teamscores")
Catch
MsgBox(Err.Number)
MsgBox(Err.Description)
End Try

An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top