本文整理汇总了C#中System.Data.SqlClient.SqlDataAdapter类的典型用法代码示例。如果您正苦于以下问题:C# SqlDataAdapter类的具体用法?C# SqlDataAdapter怎么用?C# SqlDataAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlDataAdapter类属于System.Data.SqlClient命名空间,在下文中一共展示了SqlDataAdapter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectRows
private static DataSet SelectRows(DataSet dataset,
string connectionString,string queryString)
{
using (SqlConnection connection =
new SqlConnection(connectionString))
{
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand(
queryString, connection);
adapter.Fill(dataset);
return dataset;
}
}
示例2: new SqlDataAdapter
//引入命名空间
using System;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
class MainClass
{
static void Main(string[] args)
{
SqlConnection SConn = new SqlConnection("Data Source=(local); Initial Catalog = CaseManager; Integrated Security=true");
SqlDataAdapter da = new SqlDataAdapter("SELECT ID, FirstName, LastName FROM Employee", SConn);
DataSet ds = new DataSet();
DataTableMapping custMap = da.TableMappings.Add("Employee", "MyDatabase");
custMap.ColumnMappings.Add("ID", "Number");
custMap.ColumnMappings.Add("FirstName", "first name");
custMap.ColumnMappings.Add("LastName", "last name");
da.Fill(ds);
}
}