Updating VFP databse

Billy Yang

Member
Joined
Oct 6, 2004
Messages
6
Programming Experience
3-5
Hello,

I write a small program to build a web service. I fill a dataset with data from VFP database. After I put a record in the dataset and make the update. When updating the database I get an error described like this: "System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
at VT_HRSWebServices.HRSService.UpdateObservation() in C:\Inetpub\wwwroot\VT_HRSWebServices\HRSService.asmx.vb:line 171"
The instruction where it fails is: HRSAdapterObs.Update(DSObs, "observation")
I don't know what to do to resolve this error.
Bye

Here is the code:

HRSAdapterObs.Fill(DSObs, "observation")
LNewRow = DSObs.Tables("observation").NewRow
With LNewRow
.Item("round") = 1250
.Item("date") = Today
.Item("begin_time") = "10:20"
.Item("end_time") = "10:25"
.Item("entry_date") = Today
End With

DSObs.Tables("observation").Rows.Add(LNewRow)

LRowsUpatedCount = 0
Try
HRSAdapterObs.Update(DSObs, "observation")
LRowsUpatedCount = LRowsUpatedCount + 1

Catch e As Exception
Return -1
End Try

Return LRowsUpatedCount
 
I don't know the answer to this one, but try to use the code (
VB.NET:
 and
) tags to make your question more readable.
 
I don't understand your answer, but I send all the new code, I have the same error.

Bye.

New code:
<WebMethod()> Public Function TestUpdateObservationNew() As DataSet

Dim myTableName As String = "observation"

Dim LNewRow As DataRow

Dim LHRSDS As DataSet = New DataSet("DSObs")

Try

HRSConnection.Open()

HRSAdapterObs.Fill(LHRSDS, myTableName)

' Code to modify data in DataSet here

LNewRow = LHRSDS.Tables("observation").NewRow

LHRSDS.Tables("observation").Rows.Add(LNewRow)

With LNewRow

.Item("round") = 0

.Item("date") = Today.Date

.Item("begin_time") = "10:20"

.Item("end_time") = "10:25"

.Item("int_lang") = "FRAN"

End With

HRSAdapterObs.Update(LHRSDS, myTableName)

HRSConnection.Close()

Catch e As Exception

HRSConnection.Close()

Return Nothing

End Try

Return LHRSDS

End Function

 
Back
Top