Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Silverlight SQL Webservices Error RSS

4 replies

Last post Aug 02, 2007 10:54 PM by agupta2k1

(0)
  • Lawrence 007

    Lawrence 007

    Member

    40 Points

    26 Posts

    Silverlight SQL Webservices Error

    Jul 21, 2007 11:45 AM | LINK

    Hi,

    This is new to me and basically my "Hello World" for silverlight and webservices, so please bear with me. All I want to do is log on to my SQL Database, Query and then get the results. This is what I have so far:

    Code Snippet
    Private Function GetDataSet(ByVal strSQL As String) As DataSet
    '1. Create a connection
    Dim Conn As New SqlConnectionStringBuilder()
    Conn.DataSource = "Server Name"
    Conn.InitialCatalog = "Database Name"
    Conn.UserID = "User Name"
    Conn.Password = "Password"
    Dim Connection As New SqlConnection(Conn.ConnectionString)
    '2. Create the command object, passing in the SQL string 
    Dim myCommand As New SqlCommand(strSQL, Connection)
    Connection.Open()
    '3. Create the DataAdapter
    Dim myDataAdapter As New SqlDataAdapter()
    myDataAdapter.SelectCommand = myCommand
     
    '4. Populate the DataSet and close the connection
    Dim myDataSet As New DataSet()
    myDataAdapter.Fill(myDataSet)
    Connection.Close()
    'Return the DataSet
    Return myDataSet
    End Function
     
    <WebMethod()> Public Function GetDepartMent() As DataSet
    Return GetDataSet("Select Name As Department from Department")
     
     I want to change the Text of a Textblock to the new Name of the Department. The first Error I get is the following:
    System.AsyncCallback' is a delegate type and requires a single 'addressof' expression as the only argument to the constructor.
     
     
    The second Error:
    This Webservice works fine on its own, but when I add the Web Reference to my solution I get the following error:

    Import of type 'System.ComponentModel.MarshalByValueComponent' from assembly or module 'System' failed

    I would really appretiate any help or even "You are doing it wrong do it this way" would help.

    Thank you very much!

  • Lawrence 007

    Lawrence 007

    Member

    40 Points

    26 Posts

    Re: Silverlight SQL Webservices Error

    Jul 21, 2007 03:28 PM | LINK

    Ok,

    I found my issue: I added the Reference at the wrong place.

    I am having issues in getting a textblock to display the results of this webservice. Can someone please help me with that. Below is the result of the webservice. As you can see the description is LIGHTER, ZIPPO. How do I display that text in my textblock?

    Any Help would be appretiated.

    <?xml version="1.0" encoding="utf-8" ?>

    - <DataSet xmlns="http://tempuri.org/">
    - <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    - <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
    - <xs:complexType>
    - <xs:choice minOccurs="0" maxOccurs="unbounded">
    - <xs:element name="Table">
    - <xs:complexType>
    - <xs:sequence>
      <xs:element name="Description" type="xs:string" minOccurs="0" />
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:choice>
      </xs:complexType>
      </xs:element>
      </xs:schema>
    - <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
    - <NewDataSet xmlns="">
    - <Table diffgr:id="Table1" msdata:rowOrder="0">
      <Description>LIGHTER, ZIPPO</Description>
      </Table>
      </NewDataSet>
      </diffgr:diffgram>
      </DataSet>
  • samsp

    samsp

    Member

    282 Points

    96 Posts

    Microsoft

    Re: Silverlight SQL Webservices Error

    Jul 31, 2007 10:53 PM | LINK

    The silverlight client stack doesn't include dataset/datatable, so its probably not going to deserialize correctly.

     

  • Lawrence 007

    Lawrence 007

    Member

    40 Points

    26 Posts

    Re: Silverlight SQL Webservices Error

    Aug 01, 2007 12:54 AM | LINK

    I found that out the hard way. I have been trying to get my first Webservice App to work now for the past 2 weeks. This is my hello world application and I am really getting tired of constantly running into issues.

    My latest one is when I create a silverlight app using VS 2008 I keep on getting a page error. I found that if I create a page in blend and the point my createsilverlight.js file to that it solves the issue. Now I have another one. The initialize component is not recodnized..... I will work on that later.

    All I want to do is change the textblock's text to my webservice result i.e. 'Hello World'. Since I posted this I have been working on my webservice and found the best practice is to create a List<Item> and then it returns the values in a better format. I also have an Item class in my solution, but it is really frustrating not to find anything where someone can tell you how to do that.

    I know this is new and I should probably wait a little, but I really like what was done here and really want this to work. ANY help would be appreciated.

    Thanks for the reply.

  • agupta2k1

    agupta2k1

    Member

    14 Points

    11 Posts

    Re: Re: Silverlight SQL Webservices Error

    Aug 02, 2007 10:54 PM | LINK

    Hi Lawrence

    Even I have banged my head a lot over this...passing data of query result back to uer slverlight application. Till no wmy findings are that you should return data as either string if its just a word, else as a array of string etc....