当前位置: 首页>>代码示例>>C#>>正文


C# SqliteDataAdapter.Fill方法代码示例

本文整理汇总了C#中Mono.Data.Sqlite.SqliteDataAdapter.Fill方法的典型用法代码示例。如果您正苦于以下问题:C# SqliteDataAdapter.Fill方法的具体用法?C# SqliteDataAdapter.Fill怎么用?C# SqliteDataAdapter.Fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Data.Sqlite.SqliteDataAdapter的用法示例。


在下文中一共展示了SqliteDataAdapter.Fill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDataTable

        public static DataTable GetDataTable(string query)
        {
            DataSet tempDataSet = new DataSet();
            SqliteDataAdapter tempAdapter = null;

            try
            {
                __connection.Open();
                tempAdapter = new SqliteDataAdapter(query, __connection);
                tempDataSet.Reset();
                tempAdapter.Fill(tempDataSet);

            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Error in the DataBase", ex);
            }
            finally
            {
                if (tempAdapter != null)
                    tempAdapter.Dispose();

                __connection.Close();
            }

            return tempDataSet.Tables[0];
        }
开发者ID:jhenier13,项目名称:StudyCards,代码行数:27,代码来源:SQLiteLinker.cs

示例2: ExecuteDataset

        public static DataSet ExecuteDataset(string connectionString, string commandText, params IDataParameter[] commandParameters)
        {
            using (SqliteConnection connection = new SqliteConnection(connectionString))
            {
                connection.Open();
                using (SqliteCommand command = new SqliteCommand())
                {
                    command.Connection = connection;
                    command.CommandText = commandText;
                    command.CommandType = CommandType.Text;

                    if (commandParameters != null)
                    {
                        foreach (IDataParameter p in commandParameters)
                        {
                            command.Parameters.Add(p);
                        }
                    }

                    SqliteDataAdapter adapter = new SqliteDataAdapter(command);
                    DataSet dataSet = new DataSet();
                    adapter.Fill(dataSet);
                    if (dataSet.Tables.Count == 0)
                    {
                        adapter.FillSchema(dataSet, SchemaType.Source);
                    }

                    return dataSet;
                }
            }
        }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:31,代码来源:SqliteHelper.cs

示例3: Get

 public DataSet Get(string command)
 {
     DataSet dataSet = new DataSet ();
     using (SqliteConnection sql_connection=new SqliteConnection(connectionString)) {
         SqliteDataAdapter slda=new SqliteDataAdapter(command,sql_connection);
         sql_connection.Open();
         slda.Fill(dataSet);
         sql_connection.Close();
     }
     return dataSet;
 }
开发者ID:keisec,项目名称:YADC,代码行数:11,代码来源:DatabaseAccessScript.cs

示例4: GetCatalogData

 public DataSet GetCatalogData()
 {
     using (SqliteConnection connection = new SqliteConnection(_connectionString))
     {
         SqliteDataAdapter da = new SqliteDataAdapter("select * from Products", connection);
         DataSet ds = new DataSet();
     
         da.Fill(ds);
     
         return ds;
     }
 }
开发者ID:raybeorn,项目名称:WebGoat.NET,代码行数:12,代码来源:SqliteDbProvider.cs

示例5: OnLoad

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad (e);

            DataTable dtArtists = new DataTable();

            #region fetch data for artists

            Mono.Data.Sqlite.SqliteConnection cn = new Mono.Data.Sqlite.SqliteConnection("library.sqlite");
            Mono.Data.Sqlite.SqliteCommand comm = new Mono.Data.Sqlite.SqliteCommand(cn);
            Mono.Data.Sqlite.SqliteDataAdapter adapter = new Mono.Data.Sqlite.SqliteDataAdapter(comm);
            comm.CommandText = @"
            SELECT 	name, id, fetched
            FROM 	artists
            ";
            adapter.Fill(dtArtists);

            #endregion

            if (dtArtists.Rows.Count == 0)
            {
                List<SubsonicItem> artists = Subsonic.GetIndexes();

                foreach (SubsonicItem artist in artists)
                {
                    DataRow dr = dtArtists.NewRow();
                    dr["name"] = artist.name;
                    dr["id"] = artist.id;
                    dr["feteched"] = DateTime.Now.ToString();
                    dtArtists.Rows.Add(dr);

                    comm = new Mono.Data.Sqlite.SqliteCommand(cn);
                    comm.CommandText = @"
            INSERT INTO artists (name, id, fetched)
            VALUES(@name, @id, @fetched);
            ";
                    comm.Parameters.AddWithValue("@name", artist.name);
                    comm.Parameters.AddWithValue("@id", artist.id);
                    comm.Parameters.AddWithValue("@fetched", DateTime.Now.ToString());

                    if (cn.State != ConnectionState.Open)
                        cn.Open();
                    comm.ExecuteNonQuery();
                }

                if (cn.State != ConnectionState.Closed)
                    cn.Close();
            }

            rptArtists.DataSource = dtArtists;
            rptArtists.DataBind();
        }
开发者ID:rogerstewart,项目名称:subsonic-csharp,代码行数:52,代码来源:Library.aspx.cs

示例6: ExecuteTable

		public override DataTable ExecuteTable (IDbCommand command)
		{
			if (command == null)
				throw new ArgumentException ("command");

			DataTable table = new DataTable ();
			using (command) {
				using (SqliteDataAdapter adapter = new SqliteDataAdapter (command as SqliteCommand)) {
					try {
						adapter.Fill (table);
					} catch (Exception e) {
						QueryService.RaiseException (e);
					}
				}
			}
			return table;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:17,代码来源:SqlitePooledDbConnection.cs

示例7: ExecuteDataset

        /// <summary>
        /// ���ݿ�ִ��(����DataSet)
        /// </summary>
        /// <param name="connection">���ݿ����Ӵ�</param>
        /// <param name="commandType">ָ������</param>
        /// <param name="commandText">ִ���ı�</param>
        /// <param name="commandParameters">������</param>
        /// <returns>DataSet</returns>
        public static DataSet ExecuteDataset(SqliteConnection connection, CommandType commandType, string commandText, params SqliteParameter[] commandParameters)
        {
            if (connection == null) throw new ArgumentNullException("connection");

            SqliteCommand cmd = new SqliteCommand();
            bool mustCloseConnection = false;
            PrepareCommand(cmd, connection, (SqliteTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection);

            using (SqliteDataAdapter da = new SqliteDataAdapter(cmd))
            {
                DataSet ds = new DataSet();
                da.Fill(ds);
                cmd.Parameters.Clear();
                if (mustCloseConnection)
                    connection.Close();
                return ds;
            }
        }
开发者ID:dkme,项目名称:moooyo,代码行数:26,代码来源:SqliteHelper.cs

示例8: LookupCable

    public static DataSet LookupCable(string item)
    {
        string cs = "URI=file:test.db";
        string stm = "SELECT * FROM Cable";
        DataSet ds;

        using(SqliteConnection con = new SqliteConnection(cs))
        {
            con.Open();
            ds = new DataSet();
            using(SqliteDataAdapter da
                    = new SqliteDataAdapter(stm, con))
            {
                da.Fill(ds, "Cable");
            }
            con.Close();
        }
        return ds;
    }
开发者ID:Bangsadrengur,项目名称:Kapalgrunnur,代码行数:19,代码来源:sqlApi.cs

示例9: XimarinBugzillaBug853Test

		public void XimarinBugzillaBug853Test()
                {
                        const string connectionString = "URI = file:./SqliteTest.db; Version = 3";//will be in System.Data directory
                        SqliteConnection dbConnection = new SqliteConnection(connectionString);
                        dbConnection.Open();
			SqliteCommand ClearTableEntry=new SqliteCommand("DELETE FROM Primus;",dbConnection);
			ClearTableEntry.ExecuteNonQuery();

                        SqliteDataAdapter sqliteDataAdapter = new SqliteDataAdapter("SELECT * FROM primus", dbConnection);
                        SqliteCommandBuilder builder = new SqliteCommandBuilder(sqliteDataAdapter);
			sqliteDataAdapter.InsertCommand = builder.GetInsertCommand();
                        sqliteDataAdapter.DeleteCommand = builder.GetDeleteCommand();
			
                        DataSet dataSet = new DataSet();

                        sqliteDataAdapter.Fill(dataSet, "Primus");//reset

                        DataRow rowToBeAdded = dataSet.Tables["Primus"].NewRow();
                        rowToBeAdded["id"] = 123;
                        rowToBeAdded["name"] = "Name";//not null primary key
                        rowToBeAdded["value"] = 777;

                        dataSet.Tables["Primus"].Rows.Add(rowToBeAdded);
sqliteDataAdapter.Update (dataSet, "Primus");

			//This would fail with NULL constraint violation in bug
			//report.  Because before the patch, it would create
			//a new record with all fields being null-- if the
			//exception rises, test fails
                        sqliteDataAdapter.Update (dataSet, "Primus");

                        dbConnection.Close();
                        dbConnection = null;
		}
开发者ID:EricHripko,项目名称:mono,代码行数:34,代码来源:DbDataAdapterTest.cs

示例10: ExecuteSQLQuery

        /// <summary>
        /// 
        /// </summary>
        /// <param name="db">
        /// A <see cref="Database"/>
        /// </param>
        /// <param name="queryText">
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="queryParams">
        /// A <see cref="System.String[]"/>
        /// </param>
        /// <returns>
        /// A <see cref="IResultSet"/>
        /// </returns>
        public override IResultSet ExecuteSQLQuery(Database db, string queryText, string[] queryParams)
        {
            IResultSet resultSet = null;

            if (db != null)
            {
                DbConnection connection = GetConnection(db.Name);
                if (connection != null)
                {
                    string queryString = queryText;
                    try
                    {
                        if (queryParams != null)
                        {
                            queryString = String.Format(queryString, queryParams);
                        }
                        DataSet ds = new DataSet();
                        SqliteDataAdapter adapter = new SqliteDataAdapter(queryString, (SqliteConnection)connection);
                        adapter.Fill(ds);
                        resultSet = new ResultSet(ds);
                    }
                    catch (Exception e)
                    {
                        SystemLogger.Log(SystemLogger.Module.PLATFORM, "Exception replacement strings on statement.", e);
                    }
                }
                else
                {
                    SystemLogger.Log(SystemLogger.Module.PLATFORM, "SQLiteConnection not found for database name: " + db.Name);
                }
            }
            else
            {
                SystemLogger.Log(SystemLogger.Module.PLATFORM, "Provided database is null");
            }
            return resultSet;
        }
开发者ID:lsp1357,项目名称:appverse-mobile,代码行数:52,代码来源:IPhoneDatabase.cs

示例11: Initialise

        /// <summary>
        /// <list type="bullet">
        /// <item>Initialises Inventory interface</item>
        /// <item>Loads and initialises a new SQLite connection and maintains it.</item>
        /// <item>use default URI if connect string string is empty.</item>
        /// </list>
        /// </summary>
        /// <param name="dbconnect">connect string</param>
        public void Initialise(string dbconnect)
        {
            if (!m_Initialized)
            {
                m_Initialized = true;

                if (dbconnect == string.Empty)
                {
                    dbconnect = "URI=file:inventoryStore.db,version=3";
                }
                m_log.Info("[INVENTORY DB]: Sqlite - connecting: " + dbconnect);
                conn = new SqliteConnection(dbconnect);

                conn.Open();

                Assembly assem = GetType().Assembly;
                Migration m = new Migration(conn, assem, "InventoryStore");
                m.Update();

                SqliteCommand itemsSelectCmd = new SqliteCommand(invItemsSelect, conn);
                invItemsDa = new SqliteDataAdapter(itemsSelectCmd);
                //            SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);

                SqliteCommand foldersSelectCmd = new SqliteCommand(invFoldersSelect, conn);
                invFoldersDa = new SqliteDataAdapter(foldersSelectCmd);

                ds = new DataSet();

                ds.Tables.Add(createInventoryFoldersTable());
                invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
                setupFoldersCommands(invFoldersDa, conn);
                CreateDataSetMapping(invFoldersDa, "inventoryfolders");
                m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions");

                ds.Tables.Add(createInventoryItemsTable());
                invItemsDa.Fill(ds.Tables["inventoryitems"]);
                setupItemsCommands(invItemsDa, conn);
                CreateDataSetMapping(invItemsDa, "inventoryitems");
                m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions");

                ds.AcceptChanges();
            }
        }
开发者ID:KristenMynx,项目名称:Aurora-Sim,代码行数:51,代码来源:SQLiteInventoryStore.cs

示例12: ExecuteDataSet

 public DataSet ExecuteDataSet(string sql)
 {
     using (SqliteConnection conn = new SqliteConnection(this.SqlConfig.ConnectionString))
     {
         using (SqliteCommand cmd = new SqliteCommand(sql, conn))
         {
             try
             {
                 conn.Open();
                 SqliteDataAdapter adapter = new SqliteDataAdapter(cmd);
                 DataSet ds = new DataSet();
                 adapter.Fill(ds);
                 return ds;
             }
             catch(Exception e)
             {
                 conn.Close();
                 throw new Exception(e.Message + "<br>sql:" + sql + "<br>" + e.StackTrace.Replace("\n","<br>"));
             }
             finally
             {
                 conn.Close();
             }
         }
     }
 }
开发者ID:Jeremaihloo,项目名称:CSharpProject,代码行数:26,代码来源:SQLiteDriver.cs

示例13: IsValidCustomerLogin

        public bool IsValidCustomerLogin(string email, string password)
        {
            //encode password
            string encoded_password = Encoder.Encode(password);
            
            //check email/password
            string sql = "select * from CustomerLogin where email = '" + email + "' and password = '" + 
                         encoded_password + "';";
                        
            using (SqliteConnection connection = new SqliteConnection(_connectionString))
            {
                connection.Open();

                SqliteDataAdapter da = new SqliteDataAdapter(sql, connection);
            
                //TODO: User reader instead (for all calls)
                DataSet ds = new DataSet();
            
                da.Fill(ds);
                
                try
                {
                    return ds.Tables[0].Rows.Count == 0;
                }
                catch (Exception ex)
                {
                    //Log this and pass the ball along.
                    log.Error("Error checking login", ex);
                    
                    throw new Exception("Error checking login", ex);
                }
            }
        }
开发者ID:ldemidov,项目名称:WebGoat.NET,代码行数:33,代码来源:SqliteDbProvider.cs

示例14: GetEmailByName

        public DataSet GetEmailByName(string name)
        {
            string sql = "select firstName, lastName, email from Employees where firstName like '" + name + "%' or lastName like '" + name + "%'";
            
            
            using (SqliteConnection connection = new SqliteConnection(_connectionString))
            {
                connection.Open();

                SqliteDataAdapter da = new SqliteDataAdapter(sql, connection);
                DataSet ds = new DataSet();
                da.Fill(ds);

                if (ds.Tables[0].Rows.Count == 0)
                    return null;
                else
                    return ds;
            }
        }
开发者ID:ldemidov,项目名称:WebGoat.NET,代码行数:19,代码来源:SqliteDbProvider.cs

示例15: GetCustomerDetails

        public DataSet GetCustomerDetails(string customerNumber)
        {
            string sql = "select Customers.customerNumber, Customers.customerName, Customers.logoFileName, Customers.contactLastName, Customers.contactFirstName, " +
                "Customers.phone, Customers.addressLine1, Customers.addressLine2, Customers.city, Customers.state, Customers.postalCode, Customers.country, " +
                "Customers.salesRepEmployeeNumber, Customers.creditLimit, CustomerLogin.email, CustomerLogin.password, CustomerLogin.question_id, CustomerLogin.answer " +
                "From Customers, CustomerLogin where Customers.customerNumber = CustomerLogin.customerNumber and Customers.customerNumber = " + customerNumber;

            DataSet ds = new DataSet();
            try
            {
            
                using (SqliteConnection connection = new SqliteConnection(_connectionString))
                {
                    connection.Open();

                    SqliteDataAdapter da = new SqliteDataAdapter(sql, connection);
                    da.Fill(ds);
                }

            }
            catch (Exception ex)
            {
                log.Error("Error getting customer details", ex);
                
                throw new ApplicationException("Error getting customer details", ex);
            }
            return ds;

        }
开发者ID:ldemidov,项目名称:WebGoat.NET,代码行数:29,代码来源:SqliteDbProvider.cs


注:本文中的Mono.Data.Sqlite.SqliteDataAdapter.Fill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。