Updating problem

  • Thread starter Thread starter G. Dean Blake
  • Start date Start date
G

G. Dean Blake

I have created a table by running a script from my code. I have also
created a matching dataset
loaded with data for this new table. I now have to get the data in the
dataset into the table.

I figured I would create a SqlDataAdapter and a SqlCommandBuilder and then
use ado.net to do my

update as follows....
sql = "SELECT SubID, Code, State, Market, CrewCount, DayRate, NightRate,
HolidayRate " & _
"FROM(SubServices)"
Dim da As New SqlDataAdapter(sql, cn)
Dim cb As New SqlCommandBuilder(da)
da.Update(newSSDS)

but this gets the following exception...


system.invalidOperationException

Unable to find tableMapping['Table'] or datatable 'Table'

Why am I getting this? Is there an easier way to do this?
TIA
G.
 
I tried that: da.Update(newSSDS.tables(0)) that didn't work either
G

Miha Markic said:
Dean,

Try passing DataTable instance instead of newSSDS to Update method.

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

G. Dean Blake said:
I have created a table by running a script from my code. I have also
created a matching dataset
loaded with data for this new table. I now have to get the data in the
dataset into the table.

I figured I would create a SqlDataAdapter and a SqlCommandBuilder and then
use ado.net to do my

update as follows....
sql = "SELECT SubID, Code, State, Market, CrewCount, DayRate, NightRate,
HolidayRate " & _
"FROM(SubServices)"
Dim da As New SqlDataAdapter(sql, cn)
Dim cb As New SqlCommandBuilder(da)
da.Update(newSSDS)

but this gets the following exception...


system.invalidOperationException

Unable to find tableMapping['Table'] or datatable 'Table'

Why am I getting this? Is there an easier way to do this?
TIA
G.
 
The same exception?

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

G. Dean Blake said:
I tried that: da.Update(newSSDS.tables(0)) that didn't work either
G

Miha Markic said:
Dean,

Try passing DataTable instance instead of newSSDS to Update method.

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

G. Dean Blake said:
I have created a table by running a script from my code. I have also
created a matching dataset
loaded with data for this new table. I now have to get the data in the
dataset into the table.

I figured I would create a SqlDataAdapter and a SqlCommandBuilder and then
use ado.net to do my

update as follows....
sql = "SELECT SubID, Code, State, Market, CrewCount, DayRate, NightRate,
HolidayRate " & _
"FROM(SubServices)"
Dim da As New SqlDataAdapter(sql, cn)
Dim cb As New SqlCommandBuilder(da)
da.Update(newSSDS)

but this gets the following exception...


system.invalidOperationException

Unable to find tableMapping['Table'] or datatable 'Table'

Why am I getting this? Is there an easier way to do this?
TIA
G.
 
it worked. I just had a type somewhere else.
thanks.
G
Miha Markic said:
The same exception?

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

G. Dean Blake said:
I tried that: da.Update(newSSDS.tables(0)) that didn't work either
G

Miha Markic said:
Dean,

Try passing DataTable instance instead of newSSDS to Update method.

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

I have created a table by running a script from my code. I have also
created a matching dataset
loaded with data for this new table. I now have to get the data in the
dataset into the table.

I figured I would create a SqlDataAdapter and a SqlCommandBuilder
and
then
use ado.net to do my

update as follows....
sql = "SELECT SubID, Code, State, Market, CrewCount, DayRate, NightRate,
HolidayRate " & _
"FROM(SubServices)"
Dim da As New SqlDataAdapter(sql, cn)
Dim cb As New SqlCommandBuilder(da)
da.Update(newSSDS)

but this gets the following exception...


system.invalidOperationException

Unable to find tableMapping['Table'] or datatable 'Table'

Why am I getting this? Is there an easier way to do this?
TIA
G.
 
Back
Top