OleDbDataAdapter.DeleteCommand 속성
[C#]
public static OleDbDataAdapter CreateCustomerAdapter(OleDbConnection conn)
{
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand cmd;
OleDbParameter parm;
// Create the SelectCommand.
cmd = new OleDbCommand("SELECT * FROM Customers " +
"WHERE Country = @Country AND City = @City", conn);
cmd.Parameters.Add("@Country", OleDbType.VarChar, 15);
cmd.Parameters.Add("@City", OleDbType.VarChar, 15);
da.SelectCommand = cmd;
// Create the DeleteCommand.
cmd = new OleDbCommand("DELETE FROM Customers WHERE CustomerID = @CustomerID", conn);
parm = cmd.Parameters.Add("@CustomerID", OleDbType.Char, 5, "CustomerID");
parm.SourceVersion = DataRowVersion.Original;
da.DeleteCommand = cmd;
return da;
}
OleDbDataAdapter.InsertCommand 속성
[C#]
public static OleDbDataAdapter CreateCustomerAdapter(OleDbConnection conn)
{
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand cmd;
// Create the SelectCommand.
cmd = new OleDbCommand("SELECT * FROM Customers " +
"WHERE Country = @Country AND City = @City", conn);
cmd.Parameters.Add("@Country", OleDbType.VarChar, 15);
cmd.Parameters.Add("@City", OleDbType.VarChar, 15);
cmd = new OleDbCommand("SELECT * FROM Customers " +
"WHERE Country = @Country AND City = @City", conn); @Country , @City 를 ? 로 해주세요 오류나더라... ㅡㅡㅋ
da.SelectCommand = cmd;
// Create the InsertCommand.
cmd = new OleDbCommand("INSERT INTO Customers (CustomerID, CompanyName) " +
"VALUES (@CustomerID, @CompanyName)", conn);
cmd.Parameters.Add("@CustomerID", OleDbType.Char, 5, "CustomerID");
cmd.Parameters.Add("@CompanyName", OleDbType.VarChar, 40, "CompanyName");
da.InsertCommand = cmd;
return da;
}
OleDbDataAdapter.SelectCommand 속성
[C#]
public static OleDbDataAdapter CreateCustomerAdapter(OleDbConnection conn)
{
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand cmd;
// Create the SelectCommand.
cmd = new OleDbCommand("SELECT * FROM Customers " +
"WHERE Country = @Country AND City = @City", conn);
cmd.Parameters.Add("@Country", OleDbType.VarChar, 15);
cmd.Parameters.Add("@City", OleDbType.VarChar, 15);
da.SelectCommand = cmd;
// Create the InsertCommand.
cmd = new OleDbCommand("INSERT INTO Customers (CustomerID, CompanyName) " +
"VALUES (@CustomerID, @CompanyName)", conn);
cmd.Parameters.Add("@CustomerID", OleDbType.Char, 5, "CustomerID");
cmd.Parameters.Add("@CompanyName", OleDbType.VarChar, 40, "CompanyName");
da.InsertCommand = cmd;
return da;
}
OleDbDataAdapter.UpdateCommand 속성
[C#]
public static OleDbDataAdapter CreateCustomerAdapter(OleDbConnection conn)
{
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand cmd;
OleDbParameter parm;
// Create the SelectCommand.
cmd = new OleDbCommand("SELECT * FROM Customers " +
"WHERE Country = @Country AND City = @City", conn);
cmd.Parameters.Add("@Country", OleDbType.VarChar, 15);
cmd.Parameters.Add("@City", OleDbType.VarChar, 15);
da.SelectCommand = cmd;
// Create the UpdateCommand.
cmd = new OleDbCommand("UPDATE Customers SET CustomerID = @CustomerID, CompanyName = @CompanyName " +
"WHERE CustomerID = @oldCustomerID", conn);
cmd.Parameters.Add("@CustomerID", OleDbType.Char, 5, "CustomerID");
cmd.Parameters.Add("@CompanyName", OleDbType.VarChar, 40, "CompanyName");
parm = cmd.Parameters.Add("@oldCustomerID", OleDbType.Char, 5, "CustomerID");
parm.SourceVersion = DataRowVersion.Original;
da.UpdateCommand = cmd;
return da;
}
'C#.NET DB' 카테고리의 다른 글
[DataSet]데이터셋 사용법 (0) | 2010.01.12 |
---|---|
[IMAGE] 데이터베이스에 이미지 저장하기 (1) | 2010.01.07 |
[ SqlDataSource , FilterExpression ] 초간단 데이터검색방법 , 필터링 사용 설정 (0) | 2009.12.15 |
[DataTable] 데이타테이블 간단한 사용법 및 검색방법 (0) | 2009.12.15 |
[DataSet]간단한 DataAdapter와 DataSet 만들기 (0) | 2009.12.15 |
[SqlTransaction ] ADO.NET 수동 트랜잭션을 코딩하는 방법 (0) | 2009.12.15 |
[MSDN 트렌젝션]TransactionScope (0) | 2009.12.15 |
DataTable 데이터 xml로 저장하기 (0) | 2009.12.15 |
[SqlDataSource] 웹 서버 컨트롤 개요 (0) | 2009.05.20 |
[트렌젝션]TransactionScope (0) | 2009.05.20 |