本文整理汇总了C#中System.Data.SqlTypes.SqlString.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SqlString.ToString方法的具体用法?C# SqlString.ToString怎么用?C# SqlString.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlTypes.SqlString
的用法示例。
在下文中一共展示了SqlString.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindPHkeysAndSlots
public static IEnumerable FindPHkeysAndSlots(SqlInt16 partsnap, SqlInt16 fofsnap, SqlString temp_partid_table_name, SqlInt32 numparts)
{
//string temp_partid_table = "#temp_partid_list";
List<PhkeySlot> keysAndSlots = new List<PhkeySlot>();
using (SqlConnection connection = new SqlConnection("context connection=true"))
{
connection.Open();
string getFoFGroupIDsCommandString = "select partid from " + temp_partid_table_name.ToString();
SqlCommand getFoFGroupIDsListCommand = new SqlCommand(getFoFGroupIDsCommandString, connection);
SqlDataReader getFOFGroupIDsReader = getFoFGroupIDsListCommand.ExecuteReader();
Int64[] partids = new Int64[(int) numparts];
int numlines = 0;
while (getFOFGroupIDsReader.Read())
{
partids[numlines] = Int64.Parse(getFOFGroupIDsReader["partid"].ToString());
++numlines;
}
getFOFGroupIDsReader.Close();
// Find the index blocks we need to look in
HashSet<Int64> blocks = new HashSet<Int64>();
foreach (Int64 id in partids)
{
blocks.Add((id - 1) / 1024 / 1024);
}
//means we want all snaps
string rawCommand = "";
if (partsnap < 0)
{
rawCommand = "select a.snap, a.phkey, a.slot from particleDB.dbo.index{0} a, " + temp_partid_table_name.ToString() + " b "
+ " where a.partid = b.partid";
}
else
{
rawCommand = "select a.snap, a.phkey, a.slot from particleDB.dbo.index{0} a, " + temp_partid_table_name.ToString() + " b "
+ " where a.partid = b.partid and a.snap = @partsnap";
}
foreach (Int64 blockID in blocks)
{
string joinFoFGroupIndexCommandString = string.Format(rawCommand, blockID);
SqlCommand joinFofGroupIndexCommand = new SqlCommand(joinFoFGroupIndexCommandString, connection);
SqlParameter partsnapParam = new SqlParameter("@partsnap", System.Data.SqlDbType.SmallInt);
partsnapParam.Value = partsnap;
joinFofGroupIndexCommand.Parameters.Add(partsnapParam);
SqlDataReader joinReader = joinFofGroupIndexCommand.ExecuteReader();
while (joinReader.Read())
{
int snap = Int32.Parse(joinReader["snap"].ToString());
int phkey = Int32.Parse(joinReader["phkey"].ToString());
short slot = Int16.Parse(joinReader["slot"].ToString());
PhkeySlot current = new PhkeySlot(snap, phkey, slot);
keysAndSlots.Add(current);
}
joinReader.Close();
}
}
return keysAndSlots;
}
示例2: throwExceptionIfSchemaIsEmpty
private static void throwExceptionIfSchemaIsEmpty(SqlString command, DataTable schema)
{
if (schema == null)
{
throw new InvalidResultSetException("The command [" + command.ToString() + "] did not return a result set");
}
}
示例3: GetAlterStatementWithoutSchemaBinding
public static SqlChars GetAlterStatementWithoutSchemaBinding(SqlString createStatement)
{
var startPosition = GetStartPosition(createStatement);
var regex = new Regex(@"CREATE\s+VIEW(\s*.*?\s*)WITH\s+SCHEMABINDING\s+AS");
var output = regex.Replace(createStatement.ToString(), @"ALTER VIEW$1AS", 1, startPosition);
return new SqlChars(output);
}
示例4: GetPinYin
public static SqlString GetPinYin(SqlString word)
{
// 汉字 to 拼音首字母.
string result = GetChineseSpell(word.ToString());
// 返回.
return new SqlString(result);
}
示例5: Execute
public void Execute(SqlString command)
{
SqlConnection conn = null;
try
{
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Suppress))
{
String connectionString = CreateConnectionStringToContextDatabase();
conn = new SqlConnection(connectionString);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = command.ToString();
cmd.ExecuteNonQuery();
}
}
catch (SecurityException se)
{
throw new CommandExecutorException("Error connecting to database. You may need to create tSQLt assembly with EXTERNAL_ACCESS.", se);
}
finally
{
if (conn != null)
{
conn.Close();
}
}
}
示例6: DetermineCompressionRate
public static SqlDouble DetermineCompressionRate(SqlBinary originalEncodedValue, SqlString decodedValue)
{
int decodedValueLength = decodedValue.ToString().Length;
int encodedValueLength = originalEncodedValue.Value.Length;
double rate = (double)encodedValueLength / (double)decodedValueLength;
return new SqlDouble(rate);
}
示例7: GetSkyline
public static void GetSkyline(SqlString strQuery, SqlString strOperators, SqlInt32 numberOfRecords, SqlInt32 sortType, SqlInt32 upToLevel)
{
SPMultipleSkylineBNLLevel skyline = new SPMultipleSkylineBNLLevel();
string[] additionalParameters = new string[5];
additionalParameters[4] = upToLevel.ToString();
skyline.GetSkylineTable(strQuery.ToString(), strOperators.ToString(), numberOfRecords.Value, false, Helper.CnnStringSqlclr, Helper.ProviderClr, additionalParameters, sortType.Value, true);
}
示例8: CompStrings
public CompStrings(SqlString from, SqlString to, SqlString replace, SqlString tolerance, SqlString comp) {
this.from = from.ToString();
this.to = to.ToString();
this.replace = replace.ToString();
this.tolerance = tolerance.ToString();
this.comp = comp.ToString();
}
示例9: GetParam
public static int GetParam(SqlString s)
{
// 在此处放置代码
Regex _break_comp = new Regex(@"\{\d\}", RegexOptions.Compiled);
return _break_comp.Matches(s.ToString() ).Count;
//return new SqlString("Hello");
}
示例10: countUsbLog
// 全ての件数を取得
public int[] countUsbLog()
{
int[] arrCount = new int[2];
DateTime dtToday = DateTime.Now;
string today = dtToday.ToString("yyyy-MM-dd");
try {
db.conn.Open();
// 最初のループで今日のレコード件数について取得
for (int i = 0; i < 2; i++) {
MySqlCommand commCountUsbLog = new MySqlCommand("SELECT COUNT(log_id) FROM t_log", db.conn);
// 最初の実行で今日のログを取得するSQLを実行
if (i == 0) {
SqlString condition = new SqlString(" WHERE log_time LIKE '" + today + "%'");
commCountUsbLog.CommandText += condition.ToString();
}
db.debugSql = commCountUsbLog.CommandText;
arrCount[i] = Convert.ToInt32(commCountUsbLog.ExecuteScalar());
}
db.conn.Close();
} catch (MySqlException e) {
db.exceptionMsg = "エラーコード:" + e.ErrorCode + "<br>エラー内容:" + e.Message + "<br>エラー原因:" + e.Source;
Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
Debug.WriteLine(db.exceptionMsg);
Debug.WriteLine(db.debugSql);
}
return arrCount;
}
示例11: GetSkyline
public static void GetSkyline(SqlString strQuery, SqlString strOperators, SqlInt32 numberOfRecords,
SqlInt32 sortType, SqlInt32 count, SqlInt32 dimension, SqlString algorithm, SqlBoolean hasIncomparable)
{
try
{
Type strategyType = Type.GetType("prefSQL.SQLSkyline." + algorithm.ToString());
if (!typeof (SkylineStrategy).IsAssignableFrom(strategyType))
{
throw new Exception("passed algorithm is not of type SkylineStrategy.");
}
var strategy = (SkylineStrategy) Activator.CreateInstance(strategyType);
strategy.Provider = Helper.ProviderClr;
strategy.ConnectionString = Helper.CnnStringSqlclr;
strategy.RecordAmountLimit = numberOfRecords.Value;
strategy.HasIncomparablePreferences = hasIncomparable.Value;
strategy.SortType = sortType.Value;
var skylineSample = new SkylineSampling
{
SubsetCount = count.Value,
SubsetDimension = dimension.Value,
SelectedStrategy = strategy
};
DataTable dataTableReturn = skylineSample.GetSkylineTable(strQuery.ToString(), strOperators.ToString());
SqlDataRecord dataRecordTemplate = skylineSample.DataRecordTemplateForStoredProcedure;
//throw new Exception(dataTableReturn.Rows[0].Table.Columns.Count.ToString());
if (SqlContext.Pipe != null)
{
SqlContext.Pipe.SendResultsStart(dataRecordTemplate);
foreach (DataRow recSkyline in dataTableReturn.Rows)
{
for (var i = 0; i < recSkyline.Table.Columns.Count; i++)
{
dataRecordTemplate.SetValue(i, recSkyline[i]);
}
SqlContext.Pipe.SendResultsRow(dataRecordTemplate);
}
SqlContext.Pipe.SendResultsEnd();
}
}
catch (Exception ex)
{
//Pack Errormessage in a SQL and return the result
var strError = "Error in prefSQL_SkylineSampling: ";
strError += ex.Message;
if (SqlContext.Pipe != null)
{
SqlContext.Pipe.Send(strError);
}
}
}
示例12: Accumulate
public void Accumulate(SqlString Value, SqlString delimiter)
{
_delimiter = delimiter.Value;
if (Value.IsNull == false)
{
_elements.Add(Value.ToString());
}
}
示例13: CommandCall
public static void ResultSetCapture
(SqlString Command,
SqlString rsTable1, SqlString rsColumnList1,
SqlString rsTable2, SqlString rsColumnList2
)
{
// Storage for the parameters:
CommandCall cmd = new CommandCall();
// the command to execute
cmd.Command = Command.ToString();
// the tables to hold the result sets produced
cmd.rsTable = new List<ResultTables>();
// rsTableN where N = result set sequence number
// rsColumnList is the list of columns to capture * = All
if ( rsTable1.ToString() != "")
{
cmd.rsTable.Add(new ResultTables { resultSetSeq = 1, tableName = rsTable1.ToString(), columnList = rsColumnList1.ToString().ToLower() });
}
if ( rsTable2.ToString() != "" )
{
cmd.rsTable.Add(new ResultTables { resultSetSeq = 2, tableName = rsTable2.ToString(), columnList = rsColumnList2.ToString().ToLower() });
}
//*******************************************************************
// Execute & Save results to a dataSet
DataSet CommnandResults = CommandCallUtilities.ExecCommand(cmd);
DataSet dsTargetTablesOut = CommandCallUtilities.getTargetTableMetaData(cmd);
// Build a dataset with the output tables
DataSet dsResultSetSchema = CommandCallUtilities.getResultSetMetaData(cmd);
// Use the columnList choose the columns and meta data from the result set
// and then add any columns that are missing to the target table
// Map the columns of the result set to the columns of the output table;
bool result = CommandCallUtilities.mapResultsToOutputTables(CommnandResults, dsTargetTablesOut, dsResultSetSchema, cmd);
return;
}
示例14: GetRanking
public static void GetRanking(SqlString strQuery, SqlString strSelectExtremas, SqlInt32 numberOfRecords, SqlString strRankingWeights, SqlString strRankingExpressions, SqlBoolean showInternalAttr, SqlString strColumnNames)
{
SPRanking ranking = new SPRanking();
ranking.Provider = Helper.ProviderClr;
ranking.ConnectionString = Helper.CnnStringSqlclr;
ranking.RecordAmountLimit = numberOfRecords.Value;
ranking.ShowInternalAttributes = showInternalAttr.Value;
ranking.GetRankingTable(strQuery.ToString(), false, strSelectExtremas.ToString(), strRankingWeights.ToString(), strRankingExpressions.ToString(), strColumnNames.ToString());
}
示例15: Accumulate
public void Accumulate(SqlString value, SqlString separator)
{
if (value.IsNull || separator.IsNull) return;
if (intermediateResult.Length == 0)
intermediateResult.Append(value.Value);
else
intermediateResult.Append(value.ToString().Insert(0, separator.Value));
separatorResult = separator.Value;
}