title: is there a way to query a stream in c#, ex. select * from a streamobject
body: <p>I have a file upload control in my asp.net (c#) website, which is used to upload csv files with data to be inserted into the database, my problem is that, I was not able to get the actual path of the uploaded file</p>
  
  <p>It always gave me: <code>C:\inetput\projectfolder\csvname.csv</code>
  where it should have been similar to: <code>C:\Documents and settings\Pcname\Desktop\csvname.csv</code></p>
  
  <p>but by going through the various post of file upload, i came to know that file need to be saved on the server first,</p>
  
  <p>using <code>Fileupload1.Saveas(savepath);</code></p>
  
  <p>which is mandatory to save the file in a previously specified location, where this not actually required. (since it will increase the overhead of again deleting the file).</p>
  
  <p>then what I do is as below:</p>
  
  <pre><code>bool result = true;
  strm = FileUpload1.PostedFile.InputStream;
  
  reader2 = new System.IO.StreamReader(strm);
  
  // **** new ****
  
  FileInfo fileinfo = new FileInfo(FileUpload1.PostedFile.FileName);
  
  
  string savePath = "c:\\"; // example "c:\\temp\\uploads\\"; could be any path
  
  string fileName = fileinfo.Name;
  string strFilePath = savePath.ToString();
  
  
  savePath += fileName;
  
  FileUpload1.SaveAs(savePath);
  
  string strSql = "SELECT * FROM [" + fileinfo.Name + "]";
  
  string strCSVConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFilePath + ";" + "Extended Properties='text;HDR=NO;'";
  
  // load the data from CSV to DataTable 
  
  OleDbDataAdapter oleda = new OleDbDataAdapter(strSql, strCSVConnString);
  
  DataTable dtbCSV = new DataTable();
  
  oleda.Fill(dtbCSV);
  
  if (dtbCSV.Columns.Count != 2)
  {
      result = false;
  }
  </code></pre>
  
  <p>because I want to count the number of columns in the file, I'm using the oledb reader.
  which needs a file to be queried.</p>
  
  <p>Is it possible to Query a stream? I dont want to save the file, instead just read it without saving.</p>