Beispiel #1
0
        static void testAdapter()
        {
            TemplateConnection conn = new TemplateConnection();
            TemplateDataAdapter adapter = new TemplateDataAdapter();

            adapter.SelectCommand = new TemplateCommand("select * from customers", conn);

            adapter.UpdateCommand = new TemplateCommand("update name, orderid values(@name, @orderid) where id = @id", conn);
            adapter.UpdateCommand.Parameters.Add("@name", DbType.String);
            adapter.UpdateCommand.Parameters.Add("@orderid", DbType.Int32);
            adapter.UpdateCommand.Parameters.Add("@id", DbType.Int32);

            DataSet ds = new DataSet();
            adapter.Fill(ds, "Customers");

            Console.WriteLine("------------------------");
            Console.WriteLine("Results of adapter.Fill");
            printDataSet(ds);
            Console.WriteLine("------------------------");

            ds.Tables["Customers"].Rows[2]["orderid"] = 4199;
            adapter.Update(ds, "Customers");

            Console.WriteLine("------------------------");
            Console.WriteLine("Results of adapter.Update");
            printDataSet(ds);
            Console.WriteLine("------------------------");
        }
Beispiel #2
0
        static void testReader()
        {
            TemplateConnection conn = new TemplateConnection();
            conn.Open();

            TemplateCommand cmd = new TemplateCommand("select * from customers", conn);

            IDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                Console.Write(reader.GetInt32(0) + "\t");
                Console.Write(reader.GetString(1) + "\t");
                Console.Write(reader.GetInt32(2));
                Console.WriteLine();
            }
            reader.Close();

            conn.Close();
        }
 public TemplateCommand(string cmdText, TemplateConnection connection, TemplateTransaction txn)
 {
     _cmdText = cmdText;
     _connection = connection;
     _txn = txn;
 }
 public TemplateCommand(string cmdText, TemplateConnection connection)
 {
     _cmdText = cmdText;
     _connection = connection;
 }
 internal TemplateDataReader(SampleDbResultSet resultset, TemplateConnection connection)
 {
     _resultset = resultset;
     _connection = connection;
 }
 internal TemplateDataReader(SampleDb.SampleDbResultSet resultset, TemplateConnection connection)
 {
     m_resultset  = resultset;
     m_connection = connection;
 }
Beispiel #7
0
 public TemplateCommand(string cmdText, TemplateConnection connection, TemplateTransaction txn)
 {
     m_sCmdText   = cmdText;
     m_connection = connection;
     m_txn        = txn;
 }
Beispiel #8
0
 public TemplateCommand(string cmdText, TemplateConnection connection) : this(cmdText, connection, null)
 {
 }