locked
How to Upload dataset or List<> of records RRS feed

  • Question

  • Ok so I can now download a list of records from my sql data on the windows 2008 server, but now I am lost as, how to pass a list up to the Server from the Client  PC applicaton, or the Windows Phone Application.Properties.Settings.Default.FBConnectionString this is the connection string on the server, how do I connect to the connection string on the client computer, then pass up a list of records to the server?

    Thanks Jon Stroh

    Here is my code to download from the server Service1.svc

     List<Client> clients = new List<Client>();
        using (var cnn = new SqlConnection(
      Properties.Settings.Default.FBConnectionString))
        {
          using (var cmd = new SqlCommand(
           "SELECT Code, FirstName, LastName, Name, Stable, Attention, Address, City, State, ZipCode, Phone1, Phone2, Phone3, Phone4, Phone5,PaymentMethod, Modified, PrevBalance, AcctBalance,Email1, Phone1Label, Phone2Label, Phone3Label, Phone4Label, Phone5Label, Type  " +
           "FROM Client ORDER BY LastName", cnn))
          {
            cnn.Open();
            using (SqlDataReader ClientsReader =
             cmd.ExecuteReader())
            {
              while (ClientsReader.Read())
              {
                client = new Client();
                 client.Code = ClientsReader.GetString(0);
                 if (!ClientsReader.IsDBNull(3))
                 {
                   client.Name = ClientsReader.GetString(3);
                 }
                if (!ClientsReader.IsDBNull(1))
                {
                   client.FirstName = ClientsReader.GetString  1).TrimEnd();
                }
                if (!ClientsReader.IsDBNull(2))
                {
                  client.LastName = ClientsReader.GetString(2).TrimEnd();
                }
                if (!ClientsReader.IsDBNull(4))
                { 
                client.Stable = ClientsReader.GetString(4);
                }
                if (!ClientsReader.IsDBNull(5))
                {
                  client.Attention = ClientsReader.GetString(5);
                }
                if (!ClientsReader.IsDBNull(6))
                {
                  client.Address = ClientsReader.GetString(6);
                }
                if (!ClientsReader.IsDBNull(7))
                {
                  client.City = ClientsReader.GetString(7);
                }
                if (!ClientsReader.IsDBNull(8))
                {
                  client.State = ClientsReader.GetString(8);
                }
                if (!ClientsReader.IsDBNull(9))
                {
                  client.ZipCode = ClientsReader.GetString(9);
                }
                if (!ClientsReader.IsDBNull(10))
                {
                  client.Phone1 = ClientsReader.GetString(10);
                }
                if (!ClientsReader.IsDBNull(11))
                {
                  client.Phone2 = ClientsReader.GetString(11);
                }
                if (!ClientsReader.IsDBNull(12))
                {
                  client.Phone3 = ClientsReader.GetString(12);
                }
                if (!ClientsReader.IsDBNull(13))
                {
                  client.Phone4 = ClientsReader.GetString(13);
                }
                if (!ClientsReader.IsDBNull(14))
                {
                  client.Phone5 = ClientsReader.GetString(14);
                }
                if (!ClientsReader.IsDBNull(17))
                {
                           
                
                clients.Add(client);
              }
            }
          }
        }
        
        return clients;
    
      }
    • Moved by Matt Meehan - MSFT Wednesday, April 20, 2011 9:44 PM Not related to data services (From:WCF Data Services)
    Wednesday, February 23, 2011 10:07 AM

Answers

All replies

  • Hello,

    This is not the right forum for your question, please try the ADO.NET forums.

    Thanks,

    Monica

     


    Monica Frintu
    Wednesday, April 20, 2011 7:47 PM
    Answerer
  • http://archive.msdn.microsoft.com/dataservices/Wiki/View.aspx


    Please mark the replies as answers if they help and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    • Marked as answer by JonStroh Saturday, April 30, 2011 12:38 PM
    Friday, April 29, 2011 8:53 AM
  • Thank You very much that is a great resource for samples

     

    Jon


    Thank You Jon Stroh
    Saturday, April 30, 2011 12:38 PM