Updating problem

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.
 
M

Miha Markic [MVP C#]

Dean,

Try passing DataTable instance instead of newSSDS to Update method.
 
G

G. Dean Blake

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.
 
M

Miha Markic [MVP C#]

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.
 
G

G. Dean Blake

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.
 

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