我正在使用 Microsoft Enterprise Lip II 有这种方法在网站中插入资源我得到了这个错误我不认为这是权限问题,我真的不知道如何解决它。顺便说一下我测试 connectionStrings 和它工作正常
<connectionStrings>
<add name="SiteSqlServer"
connectionString="Data Source=.;Initial Catalog=databaseName;User ID=sa;Password=***"/>
</connectionStrings>
public static int Insert(Resoursce r)
{
Database objDB = new SqlDatabase("SiteSqlServer");
int val = 0;
using (DbCommand cmd = objDB.GetStoredProcCommand("InsertResoursce"))
{
// OutParameter
objDB.AddOutParameter(cmd,"@OutResoursceID",DbType.Int32,int.MaxValue);
// iNParameter
objDB.AddInParameter(cmd, "@ModuleId", DbType.Int32, r.ModuleId);
objDB.AddInParameter(cmd, "@Summary", DbType.StringFixedLength, r.Summary);
objDB.AddInParameter(cmd, "@PageId", DbType.StringFixedLength, r.PageID);
objDB.AddInParameter(cmd, "@TypeId", DbType.Int32, r.TypeID);
objDB.AddInParameter(cmd, "@UserID", DbType.Guid, r.UserID);
objDB.AddInParameter(cmd, "@Enabled", DbType.Boolean, r.Enabled);
objDB.AddInParameter(cmd, "@SafetyAlert", DbType.Boolean, r.SafetyAlert);
objDB.AddInParameter(cmd, "@SaftyAlertText", DbType.StringFixedLength, r.SafetyAlertText);
try
{
val = objDB.ExecuteNonQuery(cmd);
if (val == 1)
{
return Convert.ToInt32(objDB.GetParameterValue(cmd, "@OutResoursceID"));
}
else
{
return -1;
}
}
catch (Exception ex)
{
throw ex;
}
}
System.ArgumentException 被捕获 HResult=-2147024809
Message=初始化字符串的格式不符合从索引 0 开始的规范。 Source=System.Data StackTrace: at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) 在 System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules)在 System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) 在 System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString,DbConnectionOptions 以前)在 System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) 在 System.Data.SqlClient.SqlConnection.set_ConnectionString(String value ) 在 Microsoft.Practices.EnterpriseLibrary.Data.Database.GetNewOpenConnection() 在 Microsoft.Practices.EnterpriseLibrary.Data.Database.GetWrappedConnection() 在 Microsoft.Practices.EnterpriseLibrary 的 Microsoft.Practices.EnterpriseLibrary.Data.Database.CreateConnection()。 Microsoft.Practices.EnterpriseLibrary.Data.Database 中的 Data.Database.GetOpenConnection()。在 C:\inetpub\wwwroot\ideaPark\DesktopModules\ResourceModule\App_Code\BOL\ResourceModule.cs:line 54