CS0246: 找不到类型或命名空间名称“DbDateAdapter”,请教各位高手,如有需要我可以发详细代码,万分感谢……
using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.Common;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
public class WebService : System.Web.Services.WebService {
public WebService()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public void ExcuteSql(string strSql)
{
//设置连接字符串
string strConn = "Data Source=ADIR;Initial Catalog=shop;User ID=sa;Password=123456";
DbProviderFactory dbProviderFactory = DbProviderFactories.GetFactory("System.Data.SqlClient");
DbConnection dbConn = dbProviderFactory.CreateConnection();//设置连接
dbConn.ConnectionString = strConn;
dbConn.Open(); //打开连接
DbCommand dbComm = dbProviderFactory.CreateCommand(); //设置命令
dbComm.Connection = dbConn; //绑定连接
dbComm.CommandText = strSql; //绑定SQL
dbComm.ExecuteNonQuery(); //执行
dbConn.Close(); //关闭连接
dbConn.Dispose();
}
public DataTable ExcuteSelect(string strSql)
{
//设置连接字符串
string strConn = "Data Source=ADIR;Initial Catalog=shop;User ID=sa;Password=123456";
DbProviderFactory dbProviderFactory = DbProviderFactories.GetFactory("System.Data.SqlClient");
DbConnection dbConn = dbProviderFactory.CreateConnection(); //设置连接
dbConn.ConnectionString = strConn;
dbConn.Open(); //打开连接
DbCommand dbComm = dbProviderFactory.CreateCommand(); //设置命令
dbComm.Connection = dbConn; //绑定连接
dbComm.CommandText = strSql; //绑定SQL
DbDateAdapter adapter = dbProviderFactory.CreateDateAdapter();
adapter.SelectCommand = dbComm;
DataSet dsDataSet = new DataSet(); //初始化DataSet
adapter.Fill(dsDataSet,"table"); //填充数据到数据表
return dsDataSet.Table["table"]; //返回数据表
}
}