本文整理汇总了C#中System.Data.SqlClient.SqlConnection.ExecSql方法的典型用法代码示例。如果您正苦于以下问题:C# SqlConnection.ExecSql方法的具体用法?C# SqlConnection.ExecSql怎么用?C# SqlConnection.ExecSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlConnection
的用法示例。
在下文中一共展示了SqlConnection.ExecSql方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResetTestTables
private void ResetTestTables()
{
using (var conn = new SqlConnection(DataSerTestHelper.DataToolsConnectionString))
{
conn.ExecSql(File.ReadAllText(@"SQL\reset_jobs_and_person.sql"));
}
}
示例2: SpecialSchemaTest
public void SpecialSchemaTest()
{
using (var conn = new SqlConnection(DataSerTestHelper.DataToolsConnectionString))
{
const string tableName = "BulkLoadTestTableSpecial";
conn.ExecSql(string.Format("DELETE FROM {0}", tableName));
var datSer = new DataTableSerializer(DataSerTestHelper.DataToolsConnectionString);
var result = datSer.ImportTable(string.Format(@"resources\dbo.{0}.xml", tableName));
DataSerTestHelper.AssertResult(result);
var tableData = conn.ExecQuery(string.Format("SELECT * FROM {0}", tableName));
Assert.AreEqual(3, tableData.Rows.Count);
}
}
示例3: LoadStandaloneTableTest
public void LoadStandaloneTableTest()
{
using (var conn = new SqlConnection(DataSerTestHelper.DataToolsConnectionString))
{
var sql = File.ReadAllText(@"SQL\reset_tools_table.sql");
conn.ExecSql(sql);
}
using (var datSer = new DataTableSerializer(DataSerTestHelper.DataToolsConnectionString))
{
var result = datSer.ImportTableWithoutBulkCopy(@"Resources\Tools.xml");
DataSerTestHelper.AssertResult(result);
}
}
示例4: DifferentSchemaTest
public void DifferentSchemaTest()
{
using (var conn = new SqlConnection(DataSerTestHelper.DataToolsConnectionString))
{
conn.ExecSql(File.ReadAllText(@"SQL\reset_BulkLoadTestTable1.sql"));
var datSer = new DataTableSerializer(DataSerTestHelper.DataToolsConnectionString);
var result = datSer.ImportTable(@"resources\dbo.BulkLoadTestTable1.xml");
DataSerTestHelper.AssertResult(result);
var tableData = conn.ExecQuery("SELECT * FROM BulkLoadTestTable1");
Assert.AreEqual(3, tableData.Rows.Count);
var firstRowData = tableData.Rows[0].ItemArray;
CollectionAssert.AreEqual(new object[] {1, "Alpha", 11, DBNull.Value}, firstRowData);
}
}