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 connectionDim 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 DataAdapterDim myDataAdapter As New SqlDataAdapter()
myDataAdapter.SelectCommand = myCommand
'4. Populate the DataSet and close the connectionDim myDataSet As New DataSet()
myDataAdapter.Fill(myDataSet)
Connection.Close()
'Return the DataSetReturn myDataSetEnd Function
<WebMethod()>
Public Function GetDepartMent() As DataSetReturn 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.
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?
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.
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....
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:
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
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" ?>
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
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
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....