【发布时间】:2015-03-13 14:56:37
【问题描述】:
我正在尝试在 C# 中使用 SMO 以编程方式更改存储过程。除了改变步骤之外,一切似乎都有效。连接和存储过程连接都很好。请帮忙,为什么它没有改变我的数据库?
using System;
using System.Data;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
namespace DBChecker
{
public class A
{
public static void Main(string[] args)
{
String sqlServerLogin = "*****";
String password = "****";
String instanceName = "";
String remoteSvrName = "****";
ServerConnection srvConn2 = new ServerConnection(remoteSvrName);
srvConn2.LoginSecure = true;
Server srv3 = new Server(srvConn2);
Console.WriteLine(srv3.Information.Version);
Console.WriteLine("Connection Established");
Database db;
db = srv3.Databases["decision"];
Console.WriteLine("DB Connection Established");
StoredProcedure sp;
sp = new StoredProcedure(db,"copy_alias_by_type");
Console.WriteLine("SP Connection Established");
sp.TextMode = false;
sp.AnsiNullsStatus = false;
sp.QuotedIdentifierStatus = false;
StoredProcedureParameter param;
param = new StoredProcedureParameter(sp, "@alstyp");
param.DataType = DataType.Char(100);
sp.Refresh();
sp.Alter();
Console.WriteLine("DataType Changed");
Console.ReadKey();
}
}
}
【问题讨论】: