0

First off I have sort of been tossed off in the deep end on this project. I have never before used Silverlight. I have been tasked with creating what in theory should be an exceptionally simple project but I am a bit stumped.

This project is very simply pulling from a SQL Server 2008 database. Inside this database there are 3 tables and 1 view. These tables basically contain a lot of data about existing projects within my company. (timeline info, estimated completion date, alloted hours/dollars for the project, etc).

I am using the Silverlight Business Application Template inside of VS 2010. I have successfully added a connection to the database via the Server Explorer and also added the ADO.NET data entity framework and domain service class. This made things very easy for the initial page that loads. I was able to drag the view i needed to the page and it displays all the data inside a datagrid. Inside of this datagrid I added a button column to enable the user to be able to view more details about a specific project.

    <sdk:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <Button Content="View Details" Click="Button_Click"></Button>
        </DataTemplate>
    </sdk:DataGridTemplateColumn.CellTemplate>

Then inside of the the Button_Click method, I have:

    string temp1 = summary1DataGrid.SelectedItem.ToString();
    string[] temp2 = new string[10];
    temp2 = temp1.Split(',');
    temp1 = temp2[3].Remove(temp2[3].IndexOf('}'));
    NavigationService.Navigate(new Uri(String.Format("Details/{0}", temp1), uriKind.Relative));

This will extract the ID number that I need from the existing datagrid and pass it the next page, where I can extract the ID number with this:

    string wbsid = NavigationContext.QueryString["id"];

This is where my problem actually starts. Basically what I need to do is query the database that I have added to this project. I want to show a datagrid that only contains data with that specific ID. I know how to do the SQL query but not sure how to incorporate all of this into a Silverlight/C# project. With that last code segment I am able to get the id that i need. Now that I have it, how do I query the database with it?

I have been researching all over the net and am having a hard time finding something that can at least point me in the right direction. If anyone can give me a bit of a hand I would greatly appreciate it. I am sorry for the long drawn out explanation, i was simply trying to give you guys all of the details that might help. Thanks in advance. Have a great day.

Oh and if you need any other information, I will be checking this frequently and will get back to you ASAP.

1 Answer 1

1

I think your task will be made easier using either WCF Data Services or WCF RIA Services. Both these technologies work with Silverlight and will allow you to interact with your database.

Remember (you may already know) that all interaction you will do from Silverlight will be asychronous and that the Silverlight application is remote from the web server that served it to you, hence getting data will involve network traffic/requests.

Hope this gives you a start.

Sign up to request clarification or add additional context in comments.

1 Comment

Alright, so I have added a Silverlight-enabled WCF Service file to my project. Are these methods just like any other normal method? i.e., I call an SqlConnection, add the connection string and then extract the data as I would in a normal c# application?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.