Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I am trying to link a Local Webservice that i made to display on a Window Phone App

This is Webservice Code:

C#
public interface IService1
  {

      // TODO: Add your service operations here

      [OperationContract]
      int CreateEvent(string Eventname, string Review, string rating);

      [OperationContract]
      int DeleteEvent(int EventID);

  }

C#
public int CreateEvent (string EventName ,string Review, string FullName  )
        {
            ConnectionStringSettingsCollection collections = ConfigurationManager.ConnectionStrings;
            string connectionString = collections["DBConnectionString"].ConnectionString;
            SqlConnection sqlconn = new SqlConnection(connectionString);
            sqlconn.Open();
            SqlCommand insertCommand = sqlconn.CreateCommand();
            insertCommand.CommandText
       = "INSERT INTO Feedback VALUES ('" +EventName+ "','"+Review+"','"+FullName+"')";

            int sucess = insertCommand.ExecuteNonQuery();
            sqlconn.Close();
                return sucess;
        }

        public int DeleteEvent (int EventID)
        {
            return 0; 
        }
    }

I have also Created a Database .mdf file with a Feedback table with the 3 items that i want to save in

As for the window Phone Side I have linked the web service and used this code which i learned from school i am not sure what it do but i presume that it is to link the database through web service

C#
private void TestWebService()
     {
         String Test = "Testing";

         ServiceReference1.Service1Client clientForTesting = new ServiceReference1.Service1Client();
         clientForTesting.GetDataUsingDataContractCompleted += clientForTesting_GetDataUsingDataContractCompleted;
         clientForTesting.GetDataUsingDataContractAsync(Test);
     }


      private void clientForTesting_GetDataUsingDataContractCompleted(object sender, ServiceReference1.GetDataUsingDataContractCompletedEventArgs e)
     {
         if (e.Error != null)
         { MessageBox.Show(e.Error.ToString()); }
         else
         {

         }


     }


This is the binding code which i use
C#
</StackPanel>
        <TextBox Text="{Binding EventName, Mode=TwoWay}" HorizontalAlignment="Left" Height="72" TextWrapping="Wrap"  VerticalAlignment="Top" Width="316" Margin="154,87,0,0" Grid.Row="1"/>
        <TextBox Text="{Binding Review, Mode=TwoWay}" HorizontalAlignment="Left" Height="72" TextWrapping="Wrap"  VerticalAlignment="Top" Width="316" Margin="154,159,0,0" Grid.Row="1"/>
        <TextBox Text="{Binding Rating, Mode=TwoWay}" HorizontalAlignment="Left" Height="72" TextWrapping="Wrap"  VerticalAlignment="Top" Width="316" Margin="154,231,0,0" Grid.Row="1"/>


it does not display anything i know that it is wrong and that is why i am here is there anyway that you can show me a working example as i am very new to window phone and online is really hard to find. I am doing this for a school project and will not earn money please help i am doing it to pass school.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900