类文件连数据库
复制内容到剪贴板
代码:
public class ConnDB
{
string SqlStr = ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString.ToString();
SqlConnection ConnStr;
public ConnDB()
{
ConnStr = new SqlConnection(SqlStr);
}
}接口
复制内容到剪贴板
代码:
public interface ILeaveword
{
SqlDataReader GetLeavewords();
........
}或取数据
复制内容到剪贴板
代码:
public SqlDataReader GetLeavewords()
{
///创建链接
///SqlConnection myConnection = new SqlConnection(
///ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString);
///用注示的没有问题
ConnDB myConnection = new ConnDB();
SqlCommand myCommand = new SqlCommand(GETLEAVEWORDS, myConnection);
.........错误信息
编译器错误信息: CS1502: 与“System.Data.SqlClient.SqlCommand.SqlCommand(string, System.Data.SqlClient.SqlConnection)”最匹配的重载方法具有一些无效参数
源错误:
行 41: ConnDB myConnection = new ConnDB();
行 42:
行 43:
SqlCommand myCommand = new SqlCommand(GETLEAVEWORDS, myConnection);
行 44:
行 45: ///定义DataReader
问题出在哪里
[
本帖最后由 moonpotato 于 2008-5-21 12:20 编辑 ]