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


C# SqlCeDataAdapter.FillSchema方法代码示例

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


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

示例1: GetColumnsFromData

		public override StiDataColumnsCollection GetColumnsFromData(StiData data, StiDataSource dataSource)
		{
			StiDataColumnsCollection dataColumns = new StiDataColumnsCollection();
			StiSqlSource sqlSource = dataSource as StiSqlSource;

			try
			{
				if (sqlSource.SqlCommand != null && sqlSource.SqlCommand.Length > 0)
				{
                    if (data.Data is SqlCeConnection)
					{
                        SqlCeConnection connection = data.Data as SqlCeConnection;
						OpenConnection(connection, data, dataSource.Dictionary);
                        using (SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(sqlSource.SqlCommand, connection))
						{
							DataTable dataTable = new DataTable();
							dataTable.TableName = sqlSource.Name;

							dataAdapter.SelectCommand.Prepare();							
														
							dataAdapter.FillSchema(dataTable, SchemaType.Source);
						
							foreach (DataColumn column in dataTable.Columns)
							{
								dataColumns.Add(new StiDataColumn(column.ColumnName, column.Caption, column.DataType));
							}

							dataTable.Dispose();
						}
						CloseConnection(data, connection);
					}
				}
			}
			catch (Exception e)
			{
				StiLogService.Write(this.GetType(), e);
			}
			
			return dataColumns;
		}
开发者ID:jamesamuir,项目名称:stimulsoft.sqlce.datapack,代码行数:40,代码来源:StiSqlCeAdapterService.cs

示例2: WriteToSQL

        public void WriteToSQL(string message, string tags, SqlCeConnection databaseConnection)
        {
            if ((_name.Length == 0) && (active == true))
             {
            throw (new ApplicationException("Can't write to log, no name set", null));
             }
             else
             {
            DataSet data = new DataSet();
            SqlCeDataAdapter adapter = new SqlCeDataAdapter(String.Format(
               "SELECT * FROM {0}", _name), databaseConnection);
            SqlCeCommandBuilder commands = new SqlCeCommandBuilder(adapter);
            adapter.FillSchema(data, SchemaType.Source, _name);

            DataRow newRow = data.Tables[_name].NewRow();
            if (message.Length > 255)
            {
               message = message.Substring(0, 255);
            }
            newRow["time"] = DateTime.UtcNow;
            newRow["tags"] = tags;
            newRow["text"] = message;

            data.Tables[_name].Rows.Add(newRow);

            adapter.Update(data, _name);
             }
        }
开发者ID:MarkPaxton,项目名称:SensorShare3,代码行数:28,代码来源:Log-dataset.cs

示例3: FillTable

        /// <summary>
        /// Заполнить таблицу на основе заданного запроса, создать адаптер данных и команды на изменение данных
        /// </summary>
        private static void FillTable(DataTable dataTable, string sql)
        {
            SqlCeDataAdapter adapter = new SqlCeDataAdapter(sql, AppData.Conn);
            adapter.ContinueUpdateOnError = true;
            adapter.FillSchema(dataTable, SchemaType.Source); // для определения свойств столбцов AllowDBNull, MaxLength
            adapter.Fill(dataTable);

            dataTable.ExtendedProperties.Add("DataAdapter", adapter);
            dataTable.BeginLoadData(); // выключить контроль ограничений вводимых данных

            SqlCeCommandBuilder builder = new SqlCeCommandBuilder(adapter);
            builder.ConflictOption = ConflictOption.OverwriteChanges;
        }
开发者ID:iyus,项目名称:scada,代码行数:16,代码来源:Tables.cs

示例4: FillTableSchema

        /// <summary>
        /// Заполнить схему данных таблицы
        /// </summary>
        public static void FillTableSchema(DataTable dataTable)
        {
            try
            {
                if (dataTable != null)
                {
                    string tableName = dataTable.TableName == "User" ? "[User]" : dataTable.TableName;
                    string sql = "select * from " + tableName;
                    SqlCeDataAdapter adapter = new SqlCeDataAdapter(sql, AppData.Conn);
                    adapter.ContinueUpdateOnError = true;
                    adapter.FillSchema(dataTable, SchemaType.Source);

                    dataTable.ExtendedProperties.Add("DataAdapter", adapter);
                    dataTable.BeginLoadData(); // выключить контроль ограничений вводимых данных

                    SqlCeCommandBuilder builder = new SqlCeCommandBuilder(adapter);
                    builder.ConflictOption = ConflictOption.OverwriteChanges;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(AppPhrases.FillSchemaError + ":\r\n" + ex.Message);
            }
        }
开发者ID:iyus,项目名称:scada,代码行数:27,代码来源:Tables.cs


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