ConnectionString 属性尚未初始化。

[复制链接]
查看11 | 回复2 | 2009-6-14 16:56:56 | 显示全部楼层 |阅读模式
行 20:
command = new OleDbCommand(SqlText,new OleDbConnection(config.DALConnectionString));
行 21:
行 22:
command.CommandType = CommandType.Text;
行 23:
command.Connection.Open();
行 24:
}
源文件: C:\Users\XXX\Documents\Visual Studio 2008\Projects\Project1\DAL\DAL\StoredProcedure.cs
行: 22
堆栈跟踪:
[InvalidOperationException: ConnectionString 属性尚未初始化。]
System.Data.OleDb.OleDbConnection.PermissionDemand() +996487
System.Data.OleDb.OleDbConnectionFactory.PermissionDemand(DbConnection outerConnection) +20
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
System.Data.OleDb.OleDbConnection.Open() +40
DAL.StoredProcedure..ctor(String SqlText) in C:\Users\XXX\Documents\Visual Studio 2008\Projects\Project1\DAL\DAL\StoredProcedure.cs:22
DAL.ExecuteSql.run(DataTable table, String sqlText) in C:\Users\XXX\Documents\Visual Studio 2008\Projects\Project1\DAL\DAL\ExecuteSql.cs:28
chatmain.Page_Load(Object sender, EventArgs e) in c:\Users\XXX\Documents\Visual Studio 2008\chatroomWebSite\chatmain.aspx.cs:25
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

谢谢

回复

使用道具 举报

千问 | 2009-6-14 16:56:56 | 显示全部楼层
command = new OleDbCommand(SqlText,new OleDbConnection(config.DALConnectionString),前面你写连接数据库字符串的那个对象名)例如:sqlconnection con=new sqlconnection (server=.;database=hr;uid=sa;pwd=1234);sqlcommand cmd=new sqlcommand("select * from employee",con);...
回复

使用道具 举报

千问 | 2009-6-14 16:56:56 | 显示全部楼层
config.DALConnectionString你这个是常量还是属性还是变量?反正没有获得....
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行