title: Executing an update stored procedure in C#
body: <p>I need to know, if I am writing the stored procedure correctly and If the C# code for executing is correct. for some reason the error being returned as is Incorrect syntax near 'c16b'. Old Error</p>
  
  <p>The new error now is: Procedure or function 'sptimeupdate' expects parameter '@date', which was not supplied.</p>
  
  <p>the nvarchar string for validating and updating in the column by ClientID is 3fc8ffa1-<strong>c16b</strong>-4d7b-9e55-1e88dfe15277, but the part in bold is only showing in the debug test intel sense in error handling</p>
  
  <pre><code>ALTER PROCEDURE sptimeupdate
      @id nvarchar(50),
      @date datetime
  AS
  BEGIN
      SET NOCOUNT ON;
      UPDATE ClientTable
      SET Today_Date=(@date)
      WHERE ClientID=(@id)
  END
  
  //--------------above stored procedure--------------------------------
  //--------------Executing the stored procedure in C#
  
   IEnumerable&lt;XElement&gt; searchClientID =
   from clientid in main.XPathSelectElements("Network/ClientID")
   where (string)clientid.Attribute("id") == IntializedPorts[i].ToString()
   select clientid;
  
  foreach (string clientid in searchClientID)
    {
       for (int up = 0; up &lt; IntializedPorts.Count(); up++)
       {
            //Update the current time in the clientid tble.
            //Renames the table copy for groups
        try
         {
           string[] Clientid; //client id array
           Clientid = new string[IntializedPorts.Count()]; //Intialization of the array
           Clientid[up] = clientid.ToString();
           DateTime td = Convert.ToDateTime(toolDate.Text); //Just added a datetime object withdate
   SqlConnection sqlConnectionCmdString = new SqlConnection(@"Data=.\SQLEXPRESS;AttachDbFilename=C:\Users\Shawn\Documents\Visual Studio 2010\Projects\Server\database\ClientRegit.mdf;Integrated Security=True;User Instance=True");
  
     //EXECUTE THE STORED PROCEDURE sptimedate
     // string UpdateCommand = "sptimeupdate" + Clientid[up].ToString() + toolDate.Text;
     string UpdateCommand = "sptimeupdate" + "'" + Clientid[up].ToString() + "'" + "'" +td.ToString()+ "'"; //this is the new UpdateCommand string as to pass parameters to stored procedure 
      SqlCommand sqlRenameCommand = new SqlCommand(UpdateCommand, sqlConnectionCmdString);
  
      sqlConnectionCmdString.Open();
      sqlRenameCommand.ExecuteNonQuery();
      sqlConnectionCmdString.Close();
    }
    catch(DataException ex)
    {                                                                                                 MessageBox.Show("Failed to UpdateCurrentTime","DataError",MessageBoxButtons.OK,MessageBoxIcon.Error);
    }
  
   }
  
  }
  </code></pre>