本文整理汇总了C#中System.Data.SqlClient.SqlDataAdapter.FillSchema方法的典型用法代码示例。如果您正苦于以下问题:C# System.Data.SqlClient.SqlDataAdapter.FillSchema方法的具体用法?C# System.Data.SqlClient.SqlDataAdapter.FillSchema怎么用?C# System.Data.SqlClient.SqlDataAdapter.FillSchema使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlDataAdapter
的用法示例。
在下文中一共展示了System.Data.SqlClient.SqlDataAdapter.FillSchema方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update_1_Row
/// <summary>
/// Update one row
/// </summary>
/// <param name="pFileString">File String</param>
/// <param name="pUpdateSQL">Update SQL Statement</param>
/// <param name="pCommand">Command</param>
/// <returns>bool</returns>
public static bool Update_1_Row(string pFileString, string pSelectSQL, string pKeyString, System.Data.Common.DbDataReader pDataReader)
{
bool result = false;
System.Data.SqlClient.SqlConnection Conn = null;
System.Data.OleDb.OleDbConnection ConnOle = null;
System.Data.SqlClient.SqlDataAdapter Adapter = null;
System.Data.OleDb.OleDbDataAdapter AdapterOle = null;
System.Data.SqlClient.SqlCommandBuilder builderSQL = null;
System.Data.OleDb.OleDbCommandBuilder builderOLE = null;
System.Data.SqlClient.SqlCommand cmdSqL = null;
System.Data.Common.DbCommand cmdOle = null;
DataSet dataSet = new DataSet();
DataTable Temp = new DataTable();
string ConnectionString = DBReadExecute.ParseConnectionString(pFileString);
StringBuilder UpdateSQL = new StringBuilder();
try
{
Type SQLServerType = Type.GetType("Epi.Data.SqlServer.SqlDBFactory, Epi.Data.SqlServer");
if (DBReadExecute.DataSource.GetType().AssemblyQualifiedName == SQLServerType.AssemblyQualifiedName)
{
//case DBReadExecute.enumDataSouce.SQLServer:
Conn = new System.Data.SqlClient.SqlConnection(ConnectionString);
Adapter = new System.Data.SqlClient.SqlDataAdapter(pSelectSQL, Conn);
//Adapter.FillSchema(dataSet, SchemaType.Source, pDestinationTableName);
Adapter.FillSchema(dataSet, SchemaType.Source);
builderSQL = new System.Data.SqlClient.SqlCommandBuilder(Adapter);
Conn.Open();
cmdSqL = Conn.CreateCommand();
cmdSqL = builderSQL.GetInsertCommand();
cmdSqL.CommandTimeout = 1500;
UpdateSQL.Append("Update ");
UpdateSQL.Append(pSelectSQL.Replace("Select * From ", ""));
UpdateSQL.Append(" Set ");
foreach (System.Data.SqlClient.SqlParameter param in cmdSqL.Parameters)
{
//string FieldName = param.ParameterName.TrimStart(new char[] { '@' });
string FieldName = param.SourceColumn;
try
{
StringBuilder TUpdateSQL = new StringBuilder();
if (pDataReader[FieldName] != DBNull.Value && !string.IsNullOrEmpty(pDataReader[FieldName].ToString()))
{
TUpdateSQL.Append("[");
TUpdateSQL.Append(FieldName);
TUpdateSQL.Append("]=");
switch (pDataReader[FieldName].GetType().ToString())
{
case "System.Boolean":
if (Convert.ToBoolean(pDataReader[FieldName]) == false)
{
TUpdateSQL.Append("0");
}
else
{
TUpdateSQL.Append("1");
}
break;
case "System.Int32":
case "System.Decimal":
case "System.Double":
case "System.Single":
case "System.Byte":
TUpdateSQL.Append(pDataReader[FieldName].ToString().Replace("'", "''"));
break;
default:
TUpdateSQL.Append("'");
TUpdateSQL.Append(pDataReader[FieldName].ToString().Replace("'", "''"));
TUpdateSQL.Append("'");
break;
}
TUpdateSQL.Append(",");
}
UpdateSQL.Append(TUpdateSQL);
}
catch (Exception ex)
{
// do nothing
}
}
UpdateSQL.Length = UpdateSQL.Length - 1;
UpdateSQL.Append(" Where ");
//.........这里部分代码省略.........