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


C# Server.SqlDataRecord类代码示例

本文整理汇总了C#中Microsoft.SqlServer.Server.SqlDataRecord的典型用法代码示例。如果您正苦于以下问题:C# SqlDataRecord类的具体用法?C# SqlDataRecord怎么用?C# SqlDataRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SqlDataRecord类属于Microsoft.SqlServer.Server命名空间,在下文中一共展示了SqlDataRecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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