Last active
          December 27, 2015 16:39 
        
      - 
      
- 
        Save hagbarddenstore/7356730 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | private IEnumerable<DataRow> RetrieveVendor(string table, string system, string region, params string[] fields) | |
| { | |
| var table = new DataTable(); | |
| var databaseFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "inu.db3"); | |
| if (!System.IO.File.Exists(databaseFile)) | |
| { | |
| MessageBox.Show(string.Format("I couldn't find the file `{0}'!", databaseFile)); | |
| } | |
| var connectionString = string.Format("Data Source={0}", databaseFile); | |
| try | |
| { | |
| using (var connection = new SQLiteConnection(connectionString)) | |
| { | |
| var query = string.Format("SELECT {0}, vpn FROM {1} WHERE system = ? AND region = ?", string.Join(", ", fields), table); | |
| using (var command = connection.CreateCommand(query)) | |
| using (var adapter = new SQLiteDataAdapter(command)) | |
| { | |
| command.Parameters.AddWithValue("@system", system); | |
| command.Parameters.AddWithValue("@region", region); | |
| connection.Open(); | |
| adapter.Fill(table); | |
| connection.Close(); | |
| } | |
| } | |
| } | |
| catch (SQLiteException exception) | |
| { | |
| MessageBox.Show(exception.ToString()); | |
| } | |
| return table.Rows; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment