David Katanski

David Katanski

  • NA
  • 4
  • 609

New to C# - Need a code check

Jul 9 2019 4:14 PM
Hello, thank you for reading.  I'm brand new to C# and C # Corner.
 
I'm working on submitting an invoice via XML, however I keep getting an error on the XmlReader line (line 13). I know the Sql connection and properties are correct becuase I copied them over from another connection in my solution that I know works.
 
Not sure what I'm missing, anyhelp would be greatly appreaciated! 
  1. public void SubmitInvoice()  
  2.  {  
  3.      SqlConnection myConnection = null;  
  4.      try  
  5.      {  
  6.          // Create Instance of Connection and Command Object  
  7.          myConnection = new SqlConnection(Settings.connectString);  
  8.          SqlCommand myCommand = new SqlCommand("usp_Get_Invoice", myConnection);  
  9.          myCommand.CommandType = CommandType.StoredProcedure;  
  10.          myCommand.CommandTimeout = 300;  
  11.          myConnection.Open();  
  12.   
  13.          XmlReader results = myCommand.ExecuteXmlReader();  
  14.          if (results.Read())  
 

Answers (2)