Larry Collette

cSharp.focus(); others.blur();

  Home  |   Contact  |   Syndication    |   Login
  3 Posts | 0 Stories | 4 Comments | 2 Trackbacks

News



Archives

Post Categories

Basic Sites

Favorite Links

Monday, January 30, 2006 #

I spent a few hours Friday night helping some friends who are going back to school to get their engineering degrees. Before the semester started, they told me how excited they were that they got to do start their first programming class in Java. Now, I have been dealing with Visual Basic and C# for the past 6-7 years, to include Classic ASP, DHTML (JavaScripts), Flash 8 Action Scripts and Cold Fusion. Never really took a gander at Java but was surprised to see how similar it was to C#. Sin

Tuesday, January 24, 2006 #

My Daily Headache / dotNet 2.0 Web Services

 

I have been developing with Visual Studio 2003 for a while and I recently convinced my company to purchase a MSDN Universal Subscription, which got me my hands on Visual Studio 2005.  Granted I went to a few live events and already received a few copies of VS 2005 Beta 2, but never had the time to get around to testing, until now.

 

My current project is to build a smart client application using FW 2.0 and secured web services w/ WSE 3.0 to a PKI (Public Key Infrastructure) enabled web application using ASP.net 1.1.

 

The current snag I have gotten myself into is the use of the Web Reference in VS 2005.  I have created a Web Service and Web Method to return the data when invoked.  I have created two methods to run tests against.

 

[WebMethod]

public myData[] getMyDataObject(int UserID) {

      return ConvertDataTableToObjectArray(new Procedures().getData(UserID));

}

 

[WebMethod]

public DataTable getMyDataTable(int UserID) {

      return new Procedures().getData(UserID));

}

 

I test this web service on the localhost just to make sure the data is returned properly when Invoked.

 

Now, on my Windows Client Application, I create my form and add the web service as my reference.  I create the object and binded it to the  DataGridView control:

 

myData[] data = new myWebService.DemoData().getMyDataObject(Member.UserID);

dataGridView1.DataSource = data;

dataGridView1.Refresh();

 

Which works fine, but I needed to filter the data.  Since this application was going to be a Smart Client, there wasn’t a point to keep going back and invoking the method, so I plan on caching the data or storing it locally in an xml until the client decides to update.  The current method receives the top 100 in a parameterized stored procedure; therefore the client is receiving all their information.

 

So I run into the issue with filtering the data.  Since I received the data as an object, I was in search of a class or method of the DataGridView control to filter and show what I need the client to see.  The best method was the filter method in BindingSource class, after trying and trying, it seemed to not work and I have no clue why:

 

myData[] data = new myWebService.DemoData().getMyDataObject(Member.UserID);

BindingSource bs = new BindingSource();

bs.DataSource = data;

bs.Filter = String.Format(“ActiveDate = ‘{0}’”, SelectedActiveDate);

dataGridView1.DataSource = bs;

dataGridView1.Refresh();

 

Since this isn’t working, I tried to go back to trying the DataView, here is where I came to a problem:

 

DataView class, correct me if I am wrong, but this class allows you to customize data from a DataTable (and nothing else???)

 

So I tried invoking Method #2 in my Web Service:

 

DataTable data = new myWebService.DemoData().getMyDataTable(Member.UserID);

DataView dv = new DataView(data);

dv.RowFilter = String.Format(“ActiveDate = ‘{0}’”, SelectedActiveDate);

dataGridView1.DataSource = dv;

dataGridView1.Refresh();

 

This is where I have found out that when you reference a WebService, VS creates a Reference.map and creating a “GenericObjectDataSource” I know damn well that my “getMyDataTable()” web method is a datatable, why does VS create this custom generic data object that I cannot convert or cast to a DataTable???  The DataType name that is created is called getMyDataTableResponsegetMyDataTableResult.datasource.  Once I set my object to this type, I just set the data source to it:

 

myWebService getMyDataTableResponsegetMyDataTableResult results =

      new myWebService.DemoData().getMyDataTable(Member.UserID);

 

dataGridView1.DataSource = results;

dataGridView1.Refresh();

 

I am still without a filter and I am about to just make date filter for the stored procedure, which makes it pointless to save the data object locally, since now I have to keep recalling the database, regardless of changes.

 

I have been staring at this thing all day, perhaps I just need another set of eyes, but with being new at the changes of VS 2005 as well as being under the gun, I am clueless of what I should do next.  What do you think or see????

 

Thanks for listening!

Larry


It's been a while, but I have set up a new blog on geekwithblogs.net.

I haven't got around to getting my web server back online.  The issue is that I never got around to updating my DSN.

Oh well.. this will do, I'm glad to be here.