日期:2014-05-18  浏览次数:20949 次

连接数据库好像有问题。。这个什么问题来的
[Microsoft][ODBC 驱动程序管理器] 驱动程序的 SQLAllocHandle on SQL_HANDLE_ENV 失败
网上找的资料都不管用
我是用SQLSERVER2008的,vs2010,
代码如下,strerror就是报上面的错误了。。。字符串是没错的,在config里读取!究竟什么问题呢,这是我刚装的sqlserver2008,我试过自己写连接都可以连,我觉得应该与代码无关吧!因为在公司的电脑都可以连的,回家调试就这样
 protected void Application_Start(object sender, EventArgs e)
  {
  String strServerName = "", strDatabase = "", strUserName = "", strPassword = "";
  string strConnection = ConfigurationManager.ConnectionStrings["DatabaseConfig"].ConnectionString;
  String[] aryConfig = strConnection.Split(';');
  for (int i = 0; i < aryConfig.Length; i++)
  {
  String[] aryConfigItem = aryConfig[i].Split('=');
  if (aryConfigItem[0] == "Data Source")
  {
  strServerName = aryConfigItem[1];
  }
  else if (aryConfigItem[0] == "Initial Catalog")
  {
  strDatabase = aryConfigItem[1];
  }
  else if (aryConfigItem[0] == "User ID")
  {
  strUserName = aryConfigItem[1];
  }
  else if (aryConfigItem[0] == "Password")
  {
  strPassword = aryConfigItem[1];
  }
  }
   
  DatabaseHandle.Initlize("sqlserver", strServerName, strDatabase, strUserName, strPassword);
  String strError=DatabaseHandle.GetErrorInfo();
  }


------解决方案--------------------
探讨
[Microsoft][ODBC 驱动程序管理器] 驱动程序的 SQLAllocHandle on SQL_HANDLE_ENV 失败
网上找的资料都不管用
我是用SQLSERVER2008的,vs2010,
代码如下,strerror就是报上面的错误了。。。字符串是没错的,在config里读取!究竟什么问题呢,这是我刚装的sqlserver2008,我试过自己写连接都可以连,我觉得应该与代……