Exemplo n.º 1
0
        static void Main(string[] args)
        {
            CDBFapi dbf = new CDBFapi();

            if (dbf.prepareNewTable(0))
            {
                dbf.addField("ID", 'N', 10);
                dbf.addField("NAME", 'C', 20);
                dbf.addField("BIRTH", 'D', 8);
                dbf.addField("WEIGHT", 'N', 10, 2);

                if (dbf.createTable("testfile.dbf"))
                {
                    Console.WriteLine("OK");
                }
                else
                {
                    Console.WriteLine("Error");
                }
                Console.ReadLine();
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            CDBFapi demo = new CDBFapi();

            if (!demo.libraryLoaded())
            {
                return;
            }

            Console.WriteLine("CDBFAPI Demo {0}\n", Process.GetCurrentProcess().MainModule.FileName);
            Console.WriteLine("CDBFAPI object {0}\n", demo);

            string filename = Process.GetCurrentProcess().MainModule.FileName;
            int    last     = filename.LastIndexOf("\\");

            filename = filename.Remove(last);
            filename = string.Concat(filename, "\\example.dbf");

            Console.WriteLine("Filename {0}", filename);

            demo.initLibrary(0, "*****@*****.**");

            if (demo.openDBFfile(filename))
            {
                Console.WriteLine("Reccount = {0} | FieldCount = {1} | RecordLength = {2}",
                                  demo.recCount(), demo.fieldCount(), demo.recordLength());

                demo.setDateFormat("dmy");

                for (int j = 0; j < demo.fieldCount(); j++)
                {
                    Console.WriteLine("{0} {1}({2}.{3})", demo.fieldName(j), demo.fieldType(j), demo.fieldLength(j), demo.fieldDecimal(j));
                }
                Console.WriteLine("");

                EncodingInfo e = null;


                for (int i = 0; i < demo.recCount(); i++)
                {
                    demo.readRecord(i);

                    for (int j = 0; j < demo.fieldCount(); j++)
                    {
                        Console.Write("{0}|", demo.getString(j));

                        /*
                         * if (demo.fieldType(j) == 'D')
                         * {
                         *  DateTime dt = demo.getDateTime(j);
                         *  Int64 ticks = demo.getTicks(j);
                         *  Console.WriteLine("\n{0} {1}", dt.ToString(), ticks.ToString());
                         *  Console.ReadLine();
                         * }
                         */
                    }
                    Console.WriteLine("");
                }

                demo.closeDBFfile();
            }

            Console.WriteLine("Press Enter to finish\n");

            Console.ReadLine();
        }