Esempio n. 1
0
    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;
    }
        private static SqlDataRecord CreateStringIdRecord(string id)
        {
            var record = new SqlDataRecord(new SqlMetaData("Id", SqlDbType.NVarChar, 16));

            record.SetSqlString(0, id);

            return record;
        }
        public void AddSurveyTokensMultiple(int surveyId, DateTime creationDate, IEnumerable<string> tokens)
        {
            SqlMetaData[] tab = { new SqlMetaData("value", SqlDbType.VarChar, 40) };
            List<SqlDataRecord> tokenList =
            tokens.Select(x => { var y = new SqlDataRecord(tab); y.SetSqlString(0, x); return y; }).ToList<SqlDataRecord>();

            SqlParameter p = new SqlParameter("@tblTokenList", SqlDbType.Structured);
            p.Direction = ParameterDirection.Input;
            p.TypeName = "dbo.VarcharTableType";
            p.Value = tokenList;

            SqlCommand cmd = new SqlCommand();
            using (SqlConnection conn = new SqlConnection(DbConnection.NewDbConnectionString))
            {
                conn.Open();
                cmd.Connection = conn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "vts_spSurveyTokenAddMultiple";
                cmd.Parameters.Add(p);
                cmd.Parameters.Add(new SqlParameter("@SurveyID", surveyId));
                cmd.Parameters.Add(new SqlParameter("@CreationDate", creationDate));

                cmd.ExecuteNonQuery();
            }
            //   SqlHelper.ExecuteNonQuery(SqlHelper.DbConnectionString, "vts_spSurveyTokenAddMultiple", pars);

        }
        public void Should_be_able_to_map_from_a_data_record()
        {
            var record = new SqlDataRecord(new[] { new SqlMetaData("column-1", SqlDbType.VarChar, 65) });

            record.SetSqlString(0, new SqlString(null));

            var column1 = new MappedColumn<string>("column-1", DbType.AnsiString, 65);
            var column2 = new MappedColumn<string>("column-2", DbType.AnsiString, 65);

            Assert.AreEqual(default(string), column1.MapFrom(record));
            Assert.AreEqual(default(string), column2.MapFrom(record));

            record.SetSqlString(0, new SqlString("value-1"));

            Assert.AreEqual("value-1", column1.MapFrom(record));
            Assert.AreEqual(default(string), column2.MapFrom(record));
        }
Esempio n. 5
0
        private static void SendCommandStatus(SqlPipe pipe, SqlInt32 status, SqlString substatus)
        {
            SqlDataRecord rec = new SqlDataRecord(
                  new SqlMetaData("Status", SqlDbType.Int)
                , new SqlMetaData("SubStatus", SqlDbType.NVarChar, 150)
                );

            SqlContext.Pipe.SendResultsStart(rec);

            rec.SetSqlInt32(0, status);
            rec.SetSqlString(1, substatus);

            pipe.SendResultsRow(rec);
            pipe.SendResultsEnd();

        }