コード例 #1
0
ファイル: ADO.cs プロジェクト: Ambratolm/oop-training
 public static int SetTable(CommandedTable ctable)
 {
     try
     {
         SqlDataAdapter    adapter        = new SqlDataAdapter(ctable.CommandText, connection);
         SqlCommandBuilder commandBuilder = new SqlCommandBuilder(adapter);
         return(adapter.Update(ctable.DataTable));
     }
     catch (Exception x)
     {
         MessageBox.Show(x.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(0);
     }
 }
コード例 #2
0
ファイル: ADO.cs プロジェクト: Ambratolm/oop-training
 public static CommandedTable GetTable(string commandText, string tableName = "")
 {
     try
     {
         SqlDataAdapter adapter = new SqlDataAdapter(commandText, connection);
         DataTable      table   = new DataTable(tableName);
         CommandedTable cTable  = new CommandedTable();
         adapter.Fill(table);
         cTable.CommandText = commandText;
         cTable.DataTable   = table;
         return(cTable);
     }
     catch (Exception x)
     {
         MessageBox.Show(x.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(null);
     }
 }