473,320 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Conversion Problem

Hi all

I have posted in .net cf but not had any joy

Maybe you can help

I have been trying to adapt the code on this page
http://support.microsoft.com/kb/310143 to work on windows mobile 5.
web application fine of course.

Load event i have changed to this

localhost.Service1 MyService = new localhost.Service1();
dataGrid1.DataSource = MyService.GetCustomers().Tables
["client"];
that work fine loads the data grid.

I have work out how to change the data in the datagrid

Problem comes when saving it back to the service

localhost.Service1 MyService = new localhost.Service1();
EXCEPTION ERROR at this line DataSet ds =
(DataSet)dataGrid1.DataSource;
DataSet
dsChanges = ds.GetChanges();
if
(dsChanges != null)
{
ds.Merge(MyService.UpdateCustomers(dsChanges),
true);
}

I think it has somthing to do with the databinding but after a couple of
evenings I now dont know where to look
any help would be apprecitated.

Thanks in advance

Roger

May 17 '07 #1
6 1363
Roger,

Well, you are setting the DataSource property to a DataTable, and trying
to cast it to a DataSet on the way out. You should be getting an
InvalidCastException here.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Roger" <ro***@barrettinteriors.co.ukwrote in message
news:A9**********************************@microsof t.com...
Hi all

I have posted in .net cf but not had any joy

Maybe you can help

I have been trying to adapt the code on this page
http://support.microsoft.com/kb/310143 to work on windows mobile 5.
web application fine of course.

Load event i have changed to this

localhost.Service1 MyService = new localhost.Service1();
dataGrid1.DataSource = MyService.GetCustomers().Tables
["client"];
that work fine loads the data grid.

I have work out how to change the data in the datagrid

Problem comes when saving it back to the service

localhost.Service1 MyService = new localhost.Service1();
EXCEPTION ERROR at this line DataSet ds =
(DataSet)dataGrid1.DataSource;
DataSet
dsChanges = ds.GetChanges();
if
(dsChanges != null)
{

ds.Merge(MyService.UpdateCustomers(dsChanges),
true);
}

I think it has somthing to do with the databinding but after a couple of
evenings I now dont know where to look
any help would be apprecitated.

Thanks in advance

Roger

May 17 '07 #2

To debug , do this:

DataSet ds =
(DataSet)dataGrid1.DataSource;

object o tempObject = dataGrid1.DataSource;
if (null!= tempObject)
{
Console.Writeline ( tempObject.ToString());
}

Put a debug line on it. When it stops there, check the Watch Window. It'll
show the object type. (This is one of several ways to see this).

But as Mark points out, you've got an object mismatch.

Once you figure it out, get rid of the tempObject code above.


"Roger" <ro***@barrettinteriors.co.ukwrote in message
news:A9**********************************@microsof t.com...
Hi all

I have posted in .net cf but not had any joy

Maybe you can help

I have been trying to adapt the code on this page
http://support.microsoft.com/kb/310143 to work on windows mobile 5.
web application fine of course.

Load event i have changed to this

localhost.Service1 MyService = new localhost.Service1();
dataGrid1.DataSource = MyService.GetCustomers().Tables
["client"];
that work fine loads the data grid.

I have work out how to change the data in the datagrid

Problem comes when saving it back to the service

localhost.Service1 MyService = new localhost.Service1();
EXCEPTION ERROR at this line DataSet ds =
(DataSet)dataGrid1.DataSource;
DataSet
dsChanges = ds.GetChanges();
if
(dsChanges != null)
{
ds.Merge(MyService.UpdateCustomers(dsChanges),
true);
}

I think it has somthing to do with the databinding but after a couple of
evenings I now dont know where to look
any help would be apprecitated.

Thanks in advance

Roger

May 17 '07 #3
Who's Mark? =)
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sloan" <sl***@ipass.netwrote in message
news:%2******************@TK2MSFTNGP06.phx.gbl...
>
To debug , do this:

DataSet ds =
>(DataSet)dataGrid1.DataSource;


object o tempObject = dataGrid1.DataSource;
if (null!= tempObject)
{
Console.Writeline ( tempObject.ToString());
}

Put a debug line on it. When it stops there, check the Watch Window.
It'll
show the object type. (This is one of several ways to see this).

But as Mark points out, you've got an object mismatch.

Once you figure it out, get rid of the tempObject code above.


"Roger" <ro***@barrettinteriors.co.ukwrote in message
news:A9**********************************@microsof t.com...
>Hi all

I have posted in .net cf but not had any joy

Maybe you can help

I have been trying to adapt the code on this page
http://support.microsoft.com/kb/310143 to work on windows mobile 5.
web application fine of course.

Load event i have changed to this

localhost.Service1 MyService = new localhost.Service1();
dataGrid1.DataSource = MyService.GetCustomers().Tables
["client"];
that work fine loads the data grid.

I have work out how to change the data in the datagrid

Problem comes when saving it back to the service

localhost.Service1 MyService = new localhost.Service1();
EXCEPTION ERROR at this line DataSet ds =
(DataSet)dataGrid1.DataSource;
DataSet
dsChanges = ds.GetChanges();
if
(dsChanges != null)
{
ds.Merge(MyService.UpdateCustomers(dsChanges),
>true);
}

I think it has somthing to do with the databinding but after a couple of
evenings I now dont know where to look
any help would be apprecitated.

Thanks in advance

Roger


May 17 '07 #4
Ok just got home from work and not digested this I guess
But why does it work in windows app and not cf

Any way I will look as you have suggested

Thanks for the replys
"Roger" <ro***@barrettinteriors.co.ukwrote in message
news:A9**********************************@microsof t.com...
Hi all

I have posted in .net cf but not had any joy

Maybe you can help

I have been trying to adapt the code on this page
http://support.microsoft.com/kb/310143 to work on windows mobile 5.
web application fine of course.

Load event i have changed to this

localhost.Service1 MyService = new localhost.Service1();
dataGrid1.DataSource = MyService.GetCustomers().Tables
["client"];
that work fine loads the data grid.

I have work out how to change the data in the datagrid

Problem comes when saving it back to the service

localhost.Service1 MyService = new localhost.Service1();
EXCEPTION ERROR at this line DataSet ds =
(DataSet)dataGrid1.DataSource;
DataSet
dsChanges = ds.GetChanges();
if
(dsChanges != null)
{

ds.Merge(MyService.UpdateCustomers(dsChanges),
true);
}

I think it has somthing to do with the databinding but after a couple of
evenings I now dont know where to look
any help would be apprecitated.

Thanks in advance

Roger
May 17 '07 #5
Good question.
I must have had 2 posts up at once or something.
I'm doing brain-dead work right now, thus my active-ness on the forums.


"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:e6**************@TK2MSFTNGP04.phx.gbl...
Who's Mark? =)
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sloan" <sl***@ipass.netwrote in message
news:%2******************@TK2MSFTNGP06.phx.gbl...

To debug , do this:

DataSet ds =
(DataSet)dataGrid1.DataSource;

object o tempObject = dataGrid1.DataSource;
if (null!= tempObject)
{
Console.Writeline ( tempObject.ToString());
}

Put a debug line on it. When it stops there, check the Watch Window.
It'll
show the object type. (This is one of several ways to see this).

But as Mark points out, you've got an object mismatch.

Once you figure it out, get rid of the tempObject code above.


"Roger" <ro***@barrettinteriors.co.ukwrote in message
news:A9**********************************@microsof t.com...
Hi all

I have posted in .net cf but not had any joy

Maybe you can help

I have been trying to adapt the code on this page
http://support.microsoft.com/kb/310143 to work on windows mobile 5.
web application fine of course.

Load event i have changed to this

localhost.Service1 MyService = new localhost.Service1();
dataGrid1.DataSource = MyService.GetCustomers().Tables
["client"];
that work fine loads the data grid.

I have work out how to change the data in the datagrid

Problem comes when saving it back to the service

localhost.Service1 MyService = new localhost.Service1();
EXCEPTION ERROR at this line DataSet ds =
(DataSet)dataGrid1.DataSource;
DataSet
dsChanges = ds.GetChanges();
if
(dsChanges != null)
{
ds.Merge(MyService.UpdateCustomers(dsChanges),
true);
}

I think it has somthing to do with the databinding but after a couple
of
evenings I now dont know where to look
any help would be apprecitated.

Thanks in advance

Roger


May 17 '07 #6
no Problem

I do know this !

DataGrid does not support databinding inn CF

Sorry about the typ of post but i cannot reply !
"Roger" <ro***@barrettinteriors.co.ukwrote in message
news:A9**********************************@microsof t.com...
Hi all

I have posted in .net cf but not had any joy

Maybe you can help

I have been trying to adapt the code on this page
http://support.microsoft.com/kb/310143 to work on windows mobile 5.
web application fine of course.

Load event i have changed to this

localhost.Service1 MyService = new localhost.Service1();
dataGrid1.DataSource = MyService.GetCustomers().Tables
["client"];
that work fine loads the data grid.

I have work out how to change the data in the datagrid

Problem comes when saving it back to the service

localhost.Service1 MyService = new localhost.Service1();
EXCEPTION ERROR at this line DataSet ds =
(DataSet)dataGrid1.DataSource;
DataSet
dsChanges = ds.GetChanges();
if
(dsChanges != null)
{

ds.Merge(MyService.UpdateCustomers(dsChanges),
true);
}

I think it has somthing to do with the databinding but after a couple of
evenings I now dont know where to look
any help would be apprecitated.

Thanks in advance

Roger
May 17 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vladimir Khvostov | last post by:
Hi, We have some DB2 table on the host that has varchar(3200) columns that are used to store binary data (I know that "varchar(3200) for bit data" should have been used, by modifying host table is...
31
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one...
11
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type...
3
by: Steve Richter | last post by:
here is a warning I am getting in a C++ .NET compile: c:\SrNet\jury\JuryTest.cpp(55) : warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied while...
0
by: VB Programmer | last post by:
Simple ASP.NET 1 site. Opened solution in beta 2 of 2.0. Ran thru conversion wizard and it states: "Conversion Complete. There were some errors during conversion." I view the conversion log...
4
by: Påhl Melin | last post by:
I have some problems using conversion operators in C++/CLI. In my project I have two ref class:es Signal and SignalMask and I have an conversion function in Signal to convert Signal:s to...
14
by: Richard G. Riley | last post by:
Would it be wrong to use "implicit casting" instead of the standards "implicit conversion" when talking about implicit conversions between certain data types. The standard mentions "explicit...
6
by: Dhirendra Singh | last post by:
Hi, The following C++ program is not compiling on my system. #include <iostream> using namespace std; class complex { double re, im; public: complex( ) :re(0), im(0) {}
4
by: Coleen | last post by:
Hi All :-) I'm new to this site. I've been trying to convert several .Net 2003 web applications and getting tons of conversion errors. I found this site to help walk me through the...
8
by: Nikola | last post by:
Hello, I'm writing a String class for C++ and I'm getting the following error message when using operator: test.cpp: In function ‘int main()’: test.cpp:7: error: ISO C++ says that these are...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.