当前位置: 首页 > 工具软件 > Database .NET > 使用案例 >

asp.net connection database compare bewteen ado.net Managed provider to ado.net sql managed provider

郭德惠
2023-12-01

 

ADO.NET Managed Provider

ADO.NET SQL Managed Provider

需要引入的Namespace

System.Data.ADO

System.Data.SQL

Connection对象

ADOConnection

SQLConnection

Command对象

ADODatasetCommand

SQLDatasetCommand

Dataset对象

Dataset

Dataset

DataReader

ADODataReader

SQLDataReader

连接数据库例子

String sConnectionString = "Provider= SQLOLEDB.1;

Data Source=localhost;

uid=sa; pwd=; Initial Catalog=pubs";

 

ADOConnection con = new ADOConnection(sConnectionString);

con.Open();

String sConnectionString = "server=localhost;uid=sa;pwd=;database=pubs";

SQLConnection con = new SQLConnection(sConnectionString);

con.Open();

 

执行SQL语句例子

ADOCommand cmd = new ADOCommand("SELECT * FROM Authors", con);

ADODataReader dr = new ADODataReader();

cmd.Execute(out dr);

SQLCommand cmd = new SQLCommand(("SELECT * FROM Authors", con);

SQLDataReader dr = new SQLDataReader();

cmd.Execute(out dr);

使用存储过程例子

ADOCommand cmd = new ADOCommand ("spGetAuthorByID", con);

cmd.CommandType = CommandType.StoredProcedure;

 

ADOParameter prmID = new ADOParameter("AuthID",

ADODataType.VarChar, 11);

 

prmID.Value = "111-11-1111";

 

cmd.SelectCommand.Parameters.Add(prmID);

 

ADODataReader dr;

cmd.Execute (out dr);

SQLCommand cmd = new SQLCommand("spGetAuthorByID", con);

cmd.CommandType = CommandType.StoredProcedure;

 

SQLParameter prmID = new SQLParameter("@AuthID",

SQLDataType.VarChar,11);

 

prmID.Value = "111-11-1111"

cmd.SelectCommand.Parameters.Add(prmID);

SQLDataReader dr;

cmd.Execute(out dr);

 类似资料:

相关阅读

相关文章

相关问答