简体   繁体   English

更改MS SQL Server版本时,软件无法运行

[英]Software is not working when MS SQL server version is changed

I'm using SQL Server 2005 database - server in my software (OS-XP). 我在我的软件(OS-XP)中使用SQL Server 2005数据库 - 服务器。 When I changed the server to SQL Server 2008 (OS-windows 7), the software didn't work. 当我将服务器更改为SQL Server 2008(OS-Windows 7)时,该软件无法正常工作。

I debugged the program and found Array index out of bounds exception in a part of a code, when I changed that code its working fine, can anyone please tell me what is the reason for the problem? 我调试了程序并在代码的一部分中发现了Array index out of bounds exception ,当我改变该代码它的工作正常时,有人可以告诉我这个问题的原因是什么?

String cnnStr = String.Format("Data Source = {0}; Initial Catalog = {1}; Integrated Security = SSPI; persist security info=False; Trusted_Connection=Yes",ServerName, Databasae);

sqlConnection = new SqlConnection(cnnStr);
sqlConnection.Open();

Original code 原始代码

 Server server = new Server(new ServerConnection(sqlConnection));
 Database db = server.Databases[Databasae];
 Table Table = new Table(db, TableName);
 Column TimeColumn = new Column(Table, "DateTime");
 TimeColumn.DataType = DataType.DateTime;
 TimeColumn.Nullable = false;
 Column ValueColumn = new Column(Table, "Value");
 ValueColumn.DataType = DataType.Float;
 ValueColumn.Nullable = false;
 Table.Columns.Add(TimeColumn);
 Table.Columns.Add(ValueColumn);
 Table.Create();

New code 新代码

 StringBuilder query = new StringBuilder();
 query.Append("CREATE TABLE ");
 query.Append(TableName);
 query.Append(" (  [DateTime] DateTime , Value float(10) )");

 SqlCommand sqlQuery = new SqlCommand(query.ToString(), sqlConnection);
 SqlDataReader reader = sqlQuery.ExecuteReader();

 reader.Close();

You need to update your SMO SDK to the SQL 2008 version and remove all of the 2005 references as you are no longer using SQL 2005. 您需要将SMO SDK更新为SQL 2008版本并删除所有2005引用,因为您不再使用SQL 2005。

You can read a bit more on the subject here: 你可以在这里阅读更多关于这个主题:

http://msdn.microsoft.com/en-us/library/ms162129.aspx http://msdn.microsoft.com/en-us/library/ms162129.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用SQL Server数据库部署软件产品的演示版本的最佳方法 - The best way to deploy a demo version of a software product using SQL Server database 由于测试计算机上的服务器版本问题,SQL Server数据库无法正常工作 - SQL Server Database not working due to server version issue on testing machine 在SQL Server中更改数据时自动刷新应用程序 - Refresh Application Automatically When Data changed in SQL Server 应用程序托管到IIS时的MS SQL Server连接问题 - MS SQL Server connectivity issue when application hosted to IIS C# - XLSX 到 SQL Server - OpenRecordSet 不适用于 C#,但适用于 MS SQL Server Management Studio - C# - XLSX to SQL Server - OpenRecordSet not working in C# but works in MS SQL Server Management Studio 下一版本的SQL SERVER中将删除MS States远程proc trans选项 - MS States remote proc trans option will be removed in Next version of SQL SERVER 仅当代码更改时才更新MS Build中的程序集版本 - Update assembly version in MS Build only if code changed SQL 服务器中的分区表,会影响我的软件吗? - Partitioning tables in SQL Server, will it affect my software? MS Access到SQL Server搜索 - MS Access to sql server searching 带有 MS SQL Server 的 PeachPie WordPress - PeachPie WordPress with MS SQL Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM