本文整理汇总了C#中Microsoft.SqlServer.Server.SqlDataRecord.SetSqlString方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataRecord.SetSqlString方法的具体用法?C# SqlDataRecord.SetSqlString怎么用?C# SqlDataRecord.SetSqlString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.SqlServer.Server.SqlDataRecord
的用法示例。
在下文中一共展示了SqlDataRecord.SetSqlString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: CreateStringIdRecord
private static SqlDataRecord CreateStringIdRecord(string id)
{
var record = new SqlDataRecord(new SqlMetaData("Id", SqlDbType.NVarChar, 16));
record.SetSqlString(0, id);
return record;
}
示例3: AddSurveyTokensMultiple
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);
}
示例4: Should_be_able_to_map_from_a_data_record
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));
}
示例5: SendCommandStatus
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();
}