Ejemplo n.º 1
0
        /// <summary>
        /// Classic ADO through Interop
        /// </summary>
        public void Example2()
        {
            // Open our Connection
            Connection conn = new Connection();

            conn.Open("Provider=SQLOLEDB;Server=localhost;" +
                      "Database=ADONET", "someuser", "", 0);
            // Query the database
            Command cmd = new Command();

            cmd.ActiveConnection = conn;
            cmd.CommandText      = "SELECT * FROM CUSTOMER";
            object     recaffected = null;
            object     prms        = new object();
            _Recordset rs          = cmd.Execute(out recaffected, ref prms, 0);

            // Dump all the records to the standard output
            while (!rs.EOF)
            {
                for (int x = 0; x < rs.Fields.Count; x++)
                {
                    Console.Write(rs.Fields[x].Value.ToString() + ":");
                }
                Console.WriteLine(""); // Endline
                rs.MoveNext();
            }

            // Clean up
            conn.Close();
        }
Ejemplo n.º 2
0
        private List <Gidy> listaWybranychGid(string nazwaListy, Procedures procId)
        {
            List <Gidy> listaGID = new List <Gidy>();

            int        listaId   = GetWindow().AllChildren[nazwaListy].Id;
            _Recordset recordset = Runtime.WindowController.GetQueueMarked((int)procId, listaId, GetCallbackThread());

            try
            {
                //jesli nie jest nic zaznaczone to recordset == null
                if (recordset != null && recordset.RecordCount > 0)
                {
                    string fieldName;
                    recordset.MoveFirst();
                    while (recordset.EOF == false)
                    {
                        ADODB.Fields fields = recordset.Fields;
                        Gidy         g      = new Gidy();

                        for (int i = 0; i < fields.Count; i++)
                        {
                            fieldName = fields[i].Name;
                            if (fieldName == "TYP")
                            {
                                g.GIDTyp = fields[i].Value.ToString();
                            }

                            if (fieldName == "FIRMA")
                            {
                                g.GIDFirma = fields[i].Value.ToString();
                            }

                            if (fieldName == "NUMER")
                            {
                                g.GIDNumer = fields[i].Value.ToString();
                            }

                            if (fieldName == "LP")
                            {
                                g.GIDLp = fields[i].Value.ToString();
                            }
                        }

                        listaGID.Add(g);
                        recordset.MoveNext();
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(listaGID);
        }