本文整理汇总了C#中Microsoft.SqlServer.Server.SqlDataRecord类的典型用法代码示例。如果您正苦于以下问题:C# SqlDataRecord类的具体用法?C# SqlDataRecord怎么用?C# SqlDataRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlDataRecord类属于Microsoft.SqlServer.Server命名空间,在下文中一共展示了SqlDataRecord类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ProcedurePatientIdGenerator
public static void ProcedurePatientIdGenerator()
{
using (SqlConnection connection = new SqlConnection(@"context connection=true"))
{
if (SqlContext.IsAvailable)
{
connection.Open();
lock (lockObject)
{
SqlCommand cmd = new SqlCommand("SELECT PatientIdGenerator FROM [dbo].[SystemSettings]", connection);
int patientId = (int)cmd.ExecuteScalar();
patientId++;
cmd = new SqlCommand("UPDATE [dbo].[SystemSettings] SET [email protected] WHERE id=1", connection);
cmd.Parameters.Add(new SqlParameter("@patientId", patientId));
cmd.ExecuteNonQuery();
// Create a record object that represents an individual row, including it's metadata.
SqlDataRecord record = new SqlDataRecord(new SqlMetaData("patientId", SqlDbType.Int));
// Populate the record.
record.SetInt32(0, patientId);
SqlContext.Pipe.Send(record);
}
}
}
}
开发者ID:Ashna,项目名称:ShayanDent,代码行数:29,代码来源:StoredProcedure.cs
示例2: GenerateMetaPropertyTable
protected static IEnumerable<SqlDataRecord> GenerateMetaPropertyTable(MetaObject o)
{
var metaFields = new List<SqlDataRecord>();
try
{
SqlMetaData[] metaData = new SqlMetaData[2];
metaData[0] = new SqlMetaData("FieldName", SqlDbType.VarChar, 30);
metaData[1] = new SqlMetaData("FieldValue", SqlDbType.VarChar, -1);
foreach (KeyValuePair<string, JToken> prop in o.MetaPropertiesObject)
{
SqlDataRecord record = new SqlDataRecord(metaData);
record.SetString(0, prop.Key);
// coming from the DB the value will be an object representing the field, with a "Value" key
// coming from the client the value will be a single value
var value = prop.Value.SelectToken("Value") ?? prop.Value;
if (value.Type == JTokenType.Null)
{
record.SetDBNull(1);
}
else
{
record.SetString(1, value.ToString());
}
metaFields.Add(record);
}
}
catch (Exception e)
{
}
return metaFields;
}
开发者ID:ha1ogen,项目名称:atlassed,代码行数:34,代码来源:MetaObjectRepository.cs
示例3: SetStringRecord_NullEmpty
public static void SetStringRecord_NullEmpty(SqlDataReader dr, string columnName, SqlDataRecord record, int ordinal)
{
if (dr[columnName] == DBNull.Value)
record.SetString(ordinal, "");
else
record.SetString(ordinal, Convert.ToString(dr[columnName]));
}
开发者ID:naimheshmati,项目名称:Sanofi,代码行数:7,代码来源:Utils.cs
示例4: SetDateTimeRecord
public static void SetDateTimeRecord(SqlDataReader dr, string columnName, SqlDataRecord record, int ordinal)
{
if (dr[columnName] == DBNull.Value)
record.SetDBNull(ordinal);
else
record.SetDateTime(ordinal, Convert.ToDateTime(dr[columnName]));
}
开发者ID:naimheshmati,项目名称:Sanofi,代码行数:7,代码来源:Utils.cs
示例5: spGetNewVestaErrands
public static void spGetNewVestaErrands(SqlDateTime date)
{
DateTime d = date.Value;
String reqStr = String.Format("http://{0}/services/internalSite/errands/sendNewVestaErrandsMails?date={1}",
UserDefinedFunctions.fGetWapServerName(), d.ToString("s"));
SqlContext.Pipe.Send(reqStr);
HttpWebRequest rq = (HttpWebRequest)WebRequest.Create(reqStr);
rq.KeepAlive = false;
XmlDocument xdoc = new XmlDocument();
using(HttpWebResponse rs = (HttpWebResponse)rq.GetResponse())
using(Stream stream = rs.GetResponseStream())
xdoc.Load(stream);
XmlNode root = xdoc["result"];
SqlDataRecord rec = new SqlDataRecord(new SqlMetaData("id", SqlDbType.NVarChar, -1),
new SqlMetaData("text", SqlDbType.NVarChar, -1),
new SqlMetaData("creator", SqlDbType.NVarChar, -1),
new SqlMetaData("email", SqlDbType.NVarChar, -1)
);
SqlContext.Pipe.SendResultsStart(rec);
foreach(XmlNode ch in root.ChildNodes)
{
rec.SetValues(ch["id"].InnerText,
ch["text"].InnerText,
ch["creator"].InnerText,
ch["email"].InnerText
);
SqlContext.Pipe.SendResultsRow(rec);
}
SqlContext.Pipe.SendResultsEnd();
}
开发者ID:ElectroService,项目名称:SIM,代码行数:32,代码来源:spGetNewVestaErrands.cs
示例6: SendDataTable
public static void SendDataTable(DataTable dt)
{
bool[] coerceToString; // Do we need to coerce this column to string?
SqlMetaData[] metaData = ExtractDataTableColumnMetaData(dt, out coerceToString);
SqlDataRecord record = new SqlDataRecord(metaData);
SqlPipe pipe = SqlContext.Pipe;
pipe.SendResultsStart(record);
try
{
foreach (DataRow row in dt.Rows)
{
for (int index = 0; index < record.FieldCount; index++)
{
object value = row[index];
if (null != value && coerceToString[index])
value = value.ToString();
record.SetValue(index, value);
}
pipe.SendResultsRow(record);
}
}
finally
{
pipe.SendResultsEnd();
}
}
开发者ID:kurochkin,项目名称:CLRFunctionsTest,代码行数:28,代码来源:DataSetUtilities.cs
示例7: FillRecord
private static SqlDataRecord FillRecord(Int32 pk, SqlDataRecord record)
{
Int32 age = SlowRandom(16, 99);
string sourceString = "Age: " + age.ToString();
DateTime sourceDate = DateTime.UtcNow;
var data = /*salt + */sourceString;
string key = "Top Secret Key";
var encData = AES.EncryptBytes(data, key);
//var encDataBytes = Encoding.Unicode.GetBytes(encData);
var decData = AES.DecryptBytes(encData, key);
var sha = new SHA256Managed();
byte[] dataSHA256 = sha.ComputeHash(encData/*Bytes*/);
sha.Dispose();
// конвертирую хеш из byte[16] в строку шестнадцатиричного формата
// (вида «3C842B246BC74D28E59CCD92AF46F5DA»)
// это опциональный этап, если вам хеш нужен в строковом виде
// string sha512hex = BitConverter.ToString(dataSHA512).Replace("-", string.Empty);
record.SetInt32(0, pk);
record.SetDateTime(1, sourceDate);
record.SetString(2, sourceString);
record.SetString(3, Convert.ToBase64String(dataSHA256)); // sha256
record.SetString(4, Convert.ToBase64String(encData)); // Encrypted
record.SetString(5, decData); // Decrypted
return record;
}
开发者ID:CatBayun,项目名称:WCF.First-Steps,代码行数:32,代码来源:SQLExtentions.cs
示例8: PR_GER_FileInfo
public static void PR_GER_FileInfo(SqlString nom_Caminho)
{
FileInfo _file = new FileInfo(nom_Caminho.Value);
List<SqlMetaData> colunas = new List<SqlMetaData>();
//new SqlMetaData("stringcol", SqlDbType.NVarChar, 128)
colunas.Add(new SqlMetaData("dat_Criacao", SqlDbType.DateTime));
colunas.Add(new SqlMetaData("dat_UltimoAcesso", SqlDbType.DateTime));
colunas.Add(new SqlMetaData("dat_UltimaEscrita", SqlDbType.DateTime));
colunas.Add(new SqlMetaData("ind_Existe", SqlDbType.Bit));
colunas.Add(new SqlMetaData("nom_Arquivo", SqlDbType.VarChar, 700));
colunas.Add(new SqlMetaData("nom_Diretorio", SqlDbType.VarChar, 700));
colunas.Add(new SqlMetaData("nom_Extensao", SqlDbType.VarChar, 700));
colunas.Add(new SqlMetaData("val_Tamanho", SqlDbType.BigInt));
SqlDataRecord record = new SqlDataRecord(colunas.ToArray());
BindFile(_file, record);
SqlContext.Pipe.Send(record);
}
开发者ID:mvasilva,项目名称:SqlServerExtension,代码行数:25,代码来源:FileManager.cs
示例9: ToSqlDataRecord
internal static SqlDataRecord ToSqlDataRecord(this EventEntry record, string instanceName, PayloadFormatting payloadFormatting)
{
var sqlDataRecord = new SqlDataRecord(SqlMetaData);
var payloadValue = payloadFormatting == PayloadFormatting.Json
? EventEntryUtil.JsonSerializePayload(record)
: EventEntryUtil.XmlSerializePayload(record);
sqlDataRecord.SetValue(0, instanceName ?? string.Empty);
sqlDataRecord.SetValue(1, record.ProviderId);
sqlDataRecord.SetValue(2, record.Schema.ProviderName ?? string.Empty);
sqlDataRecord.SetValue(3, record.EventId);
sqlDataRecord.SetValue(4, (long)record.Schema.Keywords);
sqlDataRecord.SetValue(5, (int)record.Schema.Level);
sqlDataRecord.SetValue(6, (int)record.Schema.Opcode);
sqlDataRecord.SetValue(7, (int)record.Schema.Task);
sqlDataRecord.SetValue(8, record.Timestamp);
sqlDataRecord.SetValue(9, record.Schema.Version);
sqlDataRecord.SetValue(10, (object)record.FormattedMessage ?? DBNull.Value);
sqlDataRecord.SetValue(11, (object)payloadValue ?? DBNull.Value);
sqlDataRecord.SetValue(12, record.ActivityId);
sqlDataRecord.SetValue(13, record.RelatedActivityId);
sqlDataRecord.SetValue(14, record.ProcessId);
sqlDataRecord.SetValue(15, record.ThreadId);
return sqlDataRecord;
}
开发者ID:DeHeerSoftware,项目名称:semantic-logging,代码行数:26,代码来源:EventEntryExtensions.cs
示例10: CreateStringIdRecord
private static SqlDataRecord CreateStringIdRecord(string id)
{
var record = new SqlDataRecord(new SqlMetaData("Id", SqlDbType.NVarChar, 16));
record.SetSqlString(0, id);
return record;
}
开发者ID:ovuncgursoy,项目名称:SisoDb-Provider,代码行数:8,代码来源:SqlServerIdsTableParam.cs
示例11: CreateBigIdentityIdRecord
private static SqlDataRecord CreateBigIdentityIdRecord(long id)
{
var record = new SqlDataRecord(new SqlMetaData("Id", SqlDbType.BigInt));
record.SetInt64(0, id);
return record;
}
开发者ID:ovuncgursoy,项目名称:SisoDb-Provider,代码行数:8,代码来源:SqlServerIdsTableParam.cs
示例12: GetSkylineTable
internal override DataTable GetSkylineTable(IEnumerable<object[]> database, DataTable dataTableTemplate, SqlDataRecord dataRecordTemplate, string preferenceOperators)
{
Strategy = getSPSkyline();
DataTable dt = Strategy.GetSkylineTable(database, dataTableTemplate, dataRecordTemplate, preferenceOperators, RecordAmountLimit, true, SortType, AdditionParameters);
TimeMilliseconds = Strategy.TimeInMs;
NumberOfComparisons = Strategy.NumberOfOperations;
NumberOfMoves = Strategy.NumberOfMoves;
return dt;
}
开发者ID:Bulld0zzer,项目名称:prefSQL,代码行数:9,代码来源:SkylineBNL.cs
示例13: createRecordPopulatedWithData
private static SqlDataRecord createRecordPopulatedWithData(SqlDataReader dataReader, SqlMetaData[] meta)
{
SqlDataRecord rec = new SqlDataRecord(meta);
object[] recordData = new object[dataReader.FieldCount];
dataReader.GetSqlValues(recordData);
rec.SetValues(recordData);
return rec;
}
开发者ID:DFineNormal,项目名称:tSQLt,代码行数:9,代码来源:ResultSetFilter.cs
示例14: IR_SM_AvailableObjective
public static void IR_SM_AvailableObjective()
{
using (SqlConnection con = new SqlConnection("context connection=true"))
{
SqlPipe pipe = SqlContext.Pipe;
List<SqlCommand> commands = new List<SqlCommand>();
commands.Add(new SqlCommand("SELECT distinct [BUDGETTYPECODE] as ObjectiveType, [YEAR] as YearT, BRANDCODE as BrandCode FROM [SALESBUDGET] inner join SAPRODUCTS on SAPRODUCTS.saproductcode = salesbudget.saproductcode order by BRANDCODE"));
commands.Add(new SqlCommand("SELECT distinct [type] as ObjectiveType, [year] as YearT, [brandcode] as BrandCode FROM [IR_Brand_Budget] order by brandcode"));
SqlDataRecord record = new SqlDataRecord(new SqlMetaData("ObjectiveType", SqlDbType.NVarChar, 50),
new SqlMetaData("YearT", SqlDbType.Int),
new SqlMetaData("BrandCode", SqlDbType.NVarChar, 50),
new SqlMetaData("TotalProvince", SqlDbType.NVarChar, 50));
pipe.SendResultsStart(record);
bool isTotal = true;
foreach (SqlCommand cmd in commands)
{
try
{
cmd.Connection = con;
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
string objectiveType = Convert.ToString(dr["objectivetype"]);
int year = Convert.ToInt32(dr["yeart"]);
string brandCode = Convert.ToString(dr["brandcode"]);
string totalProvince = (isTotal) ? "T" : "P";
record.SetString(0, objectiveType);
record.SetInt32(1, year);
record.SetString(2, brandCode);
record.SetString(3, totalProvince);
pipe.SendResultsRow(record);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (con != null)
con.Close();
isTotal = false;
}
}
pipe.SendResultsEnd();
}
}
开发者ID:naimheshmati,项目名称:Sanofi,代码行数:55,代码来源:IR_SM_AvailableObjective.cs
示例15: IR_SM_PriceList_PerType
public static void IR_SM_PriceList_PerType()
{
using (SqlConnection con = new SqlConnection("context connection=true"))
{
SqlPipe pipe = SqlContext.Pipe;
List<SqlCommand> commands = new List<SqlCommand>();
try
{
commands.Add(new SqlCommand("SELECT DISTINCT IR_PriceList.PRICE, IR_PriceList.YEAR AS YearT, IR_PriceList.MONTH AS MonthT, IR_PriceList.SAPRODUCTCODE, IR_PriceList.PRICETYPE FROM IR_PriceList"));
SqlDataRecord record = new SqlDataRecord(new SqlMetaData("PRICE", SqlDbType.Float),
new SqlMetaData("MonthT", SqlDbType.Int),
new SqlMetaData("YearT", SqlDbType.Int),
new SqlMetaData("SAPRODUCTCODE", SqlDbType.NVarChar, 20),
new SqlMetaData("PRICETYPE", SqlDbType.NVarChar, 20));
pipe.SendResultsStart(record);
foreach (SqlCommand cmd in commands)
{
try
{
cmd.Connection = con;
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
double price = Convert.ToDouble(dr["PRICE"]);
int month = Convert.ToInt32(dr["montht"]);
int year = Convert.ToInt32(dr["yeart"]);
string saproductcode = Convert.ToString(dr["SAPRODUCTCODE"]);
string thePriceType = Convert.ToString(dr["PRICETYPE"]);
record.SetDouble(0, price);
record.SetInt32(1, month);
record.SetInt32(2, year);
record.SetString(3, saproductcode);
record.SetString(4, thePriceType);
pipe.SendResultsRow(record);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (con != null)
con.Close();
}
}
pipe.SendResultsEnd();
}
catch (Exception ex)
{
throw ex;
}
}
}
开发者ID:naimheshmati,项目名称:Sanofi,代码行数:55,代码来源:IR_SM_PriceList_PerType.cs
示例16: BindFile
private static void BindFile(FileInfo _file, SqlDataRecord record)
{
record.SetSqlDateTime(0, _file.Exists ? _file.CreationTime : SqlDateTime.Null);
record.SetSqlDateTime(1, _file.Exists ? _file.LastAccessTime : SqlDateTime.Null);
record.SetSqlDateTime(2, _file.Exists ? _file.LastWriteTime : SqlDateTime.Null);
record.SetSqlBoolean(3, _file.Exists);
record.SetString(4, _file.Name);
record.SetString(5, _file.DirectoryName);
record.SetString(6, _file.Extension);
record.SetSqlInt64(7, _file.Exists ? _file.Length : SqlInt64.Null);
}
开发者ID:mvasilva,项目名称:SqlServerExtension,代码行数:11,代码来源:FileManager.cs
示例17: GetConnectedPublnSets
public static void GetConnectedPublnSets()
{
using (var connection = new SqlConnection("context connection=true"))
{
connection.Open();
using (SqlCommand command = connection.CreateCommand())
{
SqlDataRecord record = new SqlDataRecord(new SqlMetaData[] {
new SqlMetaData("cluster", SqlDbType.Int),
new SqlMetaData("new_id", SqlDbType.Int)
});
SqlContext.Pipe.SendResultsStart(record);
List<int> publnUT = new List<int>();
List<int> pubMinPairIndex = new List<int>();
List<int> pubMaxPairIndex = new List<int>();
List<int> pairPub2Index = new List<int>();
command.CommandText = string.Format("select new_id, min_pair_index, max_pair_index from tmp_publns4 order by pub_index");
using (SqlDataReader reader = command.ExecuteReader())
while (reader.Read())
{
publnUT.Add(reader.GetInt32(0));
pubMinPairIndex.Add(reader.GetInt32(1));
pubMaxPairIndex.Add(reader.GetInt32(2));
}
command.CommandText = string.Format("select publn2_index from tmp_publn_pairs3 order by pair_index");
using (SqlDataReader reader = command.ExecuteReader())
while (reader.Read())
pairPub2Index.Add(reader.GetInt32(0));
ConnectedPubSetSearcher connectedPubSetSearcher = new ConnectedPubSetSearcher(pubMinPairIndex, pubMaxPairIndex, pairPub2Index);
List<List<int>> connectedPubSets = connectedPubSetSearcher.getConnectedPubSets();
for (int i = 0; i < connectedPubSets.Count; i++)
{
record.SetValue(0, i);
for (int j = 0; j < connectedPubSets[i].Count; j++)
{
record.SetValue(1, publnUT[connectedPubSets[i][j]]);
SqlContext.Pipe.SendResultsRow(record);
}
}
SqlContext.Pipe.SendResultsEnd();
}
}
}
开发者ID:yngcan,项目名称:TLS214-Disambiguation,代码行数:53,代码来源:SqlStoredProcedure2.cs
示例18: GerarEventoAuditoria
public static void GerarEventoAuditoria(this DbContext context, int codigoTipoEventoAuditoria, Func<int> idUsuarioFunc, params ParametroEvento[] parametrosEvento)
{
string siglaSistemaPermisys = ConfigurationManager.AppSettings["Permisys.SiglaSistema"];
string siglaModuloPermisys = ConfigurationManager.AppSettings["Permisys.SiglaModulo"];
if (string.IsNullOrWhiteSpace("Permisys.SiglaSistema") || string.IsNullOrWhiteSpace("Permisys.SiglaModulo")) {
throw new Exception("As configurações \"Permisys.SiglaSistema\" e \"Permisys.SiglaModulo\" são obrigatórias.");
}
if (idUsuarioFunc == null) {
throw new Exception("A função de obtenção do ID do usuário é obrigatória.");
}
int idUsuarioPermisys = idUsuarioFunc();
List<SqlDataRecord> parametros = null;
if (parametrosEvento != null && parametrosEvento.Count() > 0) {
parametros = new List<SqlDataRecord>();
SqlMetaData[] rowMetadata = new SqlMetaData[] {
new SqlMetaData("ORDEM", SqlDbType.Int),
new SqlMetaData("NOME", SqlDbType.VarChar, 20),
new SqlMetaData("VALOR", SqlDbType.VarChar, 100)
};
foreach (var parametro in parametrosEvento) {
if (string.IsNullOrWhiteSpace(parametro.Nome) || string.IsNullOrWhiteSpace(parametro.Valor)) {
throw new Exception("O \"Nome\" e \"Valor\" são obrigatórios para todos os parâmetros.");
}
SqlDataRecord row = new SqlDataRecord(rowMetadata);
row.SetInt32(0, parametro.Ordem);
row.SetString(1, parametro.Nome);
row.SetString(2, parametro.Valor);
parametros.Add(row);
}
}
context.Database.ExecuteSqlCommand("LOGSYS.SP_GERAR_EVENTO_AUDITORIA @SIGLA_SISTEMA_PERMISYS, @SIGLA_MODULO_PERMISYS, @ID_USUARIO_PERMISYS, @CODIGO_TIPO_EVENTO_AUDITORIA, @PARAMETROS_EVENTO",
new object[] {
new SqlParameter("SIGLA_SISTEMA_PERMISYS", SqlDbType.VarChar, 30) { Value = siglaSistemaPermisys },
new SqlParameter("SIGLA_MODULO_PERMISYS", SqlDbType.VarChar, 30) { Value = siglaModuloPermisys },
new SqlParameter("ID_USUARIO_PERMISYS", SqlDbType.Int) { Value = idUsuarioPermisys },
new SqlParameter("CODIGO_TIPO_EVENTO_AUDITORIA", SqlDbType.Int) { Value = codigoTipoEventoAuditoria },
new SqlParameter("PARAMETROS_EVENTO", SqlDbType.Structured) { TypeName = "LOGSYS.LOGSYS_LISTA_PARAMETROS", Value = parametros }
}
);
}
开发者ID:baltazzar,项目名称:NETCommons,代码行数:51,代码来源:LogSysExtension.cs
示例19: buildRecord
private static SqlDataRecord buildRecord(SqlMetaData[] metadata,EventLogEntry entry)
{
SqlDataRecord record = new SqlDataRecord(metadata);
record.SetSqlInt32(0, entry.Index);
record.SetSqlInt64(1, entry.InstanceId);
record.SetSqlDateTime(2, entry.TimeWritten);
record.SetSqlString(3, entry.MachineName);
record.SetSqlString(4, entry.Source);
record.SetSqlString(5, entry.UserName);
record.SetSqlString(6, entry.Message);
return record;
}
开发者ID:csilbergleith,项目名称:CLRLogReader,代码行数:14,代码来源:LogEntries.cs
示例20: SendStart
public SqlDataRecord SendStart(DataTable dt)
{
if (SqlContext.IsAvailable && SqlContext.Pipe != null)
{
IEnumerable<SqlMetaData> metaData =
dt.Columns.Cast<DataColumn>()
.Select(c => new SqlMetaData(c.ColumnName, SqlDbType.VarChar, SqlMetaData.Max));
var dataRecord = new SqlDataRecord(metaData.ToArray());
SqlContext.Pipe.SendResultsStart(dataRecord);
return dataRecord;
}
return null;
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:14,代码来源:SqlCtx.cs
注:本文中的Microsoft.SqlServer.Server.SqlDataRecord类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论