示例#1
0
        public static BindingSource GetBindingSource(OleDbCommand cmd, OleDbConnection conn)
        {
            //declare our binding source
            BindingSource oBindingSource = new BindingSource();

            cmd.Connection = conn;
            // Create a new data adapter based on the specified query.
            OleDbDataAdapter daGet = new OleDbDataAdapter(cmd);
            // Populate a new data table and bind it to the BindingSource.
            DataTable dtGet = new DataTable();

            //set the timeout of the OleDbCommandObject
            cmd.CommandTimeout = 240;
            dtGet.Locale       = System.Globalization.CultureInfo.InvariantCulture;
            try
            {
                //fill the DataTable with the OleDbDataAdapter
                daGet.Fill(dtGet);
            }
            //check for errors
            catch (Exception ex)
            {
                throw new Exception("Failed to Execute :" + cmd.ToString() + "\n" + ex.Message);
                return(null);
            }
            //set the DataSource for the BindingSource to the DataTable
            oBindingSource.DataSource = dtGet;
            //return the BindingSource to the calling method or control
            return(oBindingSource);
        }
示例#2
0
 public string AendernArtikelPreis(int gridIndex, double neuPreis)
 {
     try
     {
         dbcmd = new OleDbCommand("SELECT * FROM Artikel1 WHERE Art1Nr=" + gridIndex + ";", dbcon);
         dbcon.Open();
         dataReader = null;
         dataReader = dbcmd.ExecuteReader();
         dataReader.Read();
     }
     catch (Exception a)
     {
         throw a;
     }
     try
     {
         dbcmd = new OleDbCommand("INSERT INTO Artikel1 (Art1Nr, Art1StartDat, Art1Bez, Art1Bestand, Art1Stückpreis) values (" + dataReader.GetInt32(0) + ",'" + DateTime.Today.Date.ToString("dd.MM.yyyy") + "','" + dataReader.GetString(2) + "'," + dataReader.GetInt32(3) + "," + neuPreis + ")", dbcon);
         dbcmd.ExecuteNonQuery();
     }
     catch (Exception a)
     {
         throw a;
     }
     finally
     {
         dbcon.Close();
     }
     return(dbcmd.ToString());;
 }
示例#3
0
        public void idgetir()
        {
            baglan.Open();
            OleDbCommand komut  = new OleDbCommand();
            var          lastId = new OleDbCommand("SELECT LAST(StokNo) FROM Stok", baglan).ExecuteScalar().ToString();
            int          lastid = Convert.ToInt16(lastId.ToString()) + 1;

            txtStokNo.Text = lastid.ToString();
            baglan.Close();
        }
示例#4
0
        private static void Test_Command_Cancel()
        {
            using (OleDbCommand cmd = new OleDbCommand("select * from code;", conn))
            {
                cmd.ExecuteReader();
                cmd.Cancel();

                OleDbCommand cmd_clone = cmd.Clone();
                Assert.AreEqual(cmd.ToString(), cmd_clone.ToString());
            }
        }
        public void comando(string c)
        {
            OleDbConnectionStringBuilder documentos = new OleDbConnectionStringBuilder();

            documentos.DataSource = "documentos.accdb";
            documentos.Provider   = "Microsoft.Jet.OLEDB.4.0";
            OleDbConnection conexion = new OleDbConnection(documentos.ToString());

            conexion.Open();
            OleDbCommand cmd = new OleDbCommand(c, conexion);

            cmd.ExecuteNonQuery();
            cmd.ToString();
            conexion.Close();
        }
示例#6
0
 public Taxe()
 {
     InitializeComponent();
     try {
         data = new DataTable();
         OleDbCommand cmd = new OleDbCommand("SELECT * FROM Taxe");
         adp = new OleDbDataAdapter(cmd.ToString(), Program.Con);
         adp.Fill(data);
         adp.FillSchema(data, SchemaType.Source);
         bs                       = new BindingSource();
         bs.DataSource            = data;
         dataGridView1.DataSource = bs;
         txtcodeN.DataBindings.Add("text", bs, "code");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }