Updatring VFP database

G

Guest

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
 
K

Ken Tucker [MVP]

Hi,

I am guessing that you never created an updatecommand for the
dataadapter. Take a look at the command builder class.

http://msdn.microsoft.com/library/d...plecreatingdatacommandswithcommandbuilder.asp


Ken
---------------------
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
 

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