本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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);
}
}