本文介绍了C#,SQL-DMO,添加文件组问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候所有,我希望有人可以在这个问题上放弃一些

。我正在尝试将文件组/数据文件添加到

现有SQL数据库中。下面的代码编译并在.NET中运行

Studio,但是没有任何反应?表单关闭,没有错误消息

被抛出,没有任何类型的错误发生的迹象。

最终结果(假设代码是正确的)是应该有一个新的

文件组,其中包含数据文件,这里是代码:

********************************************* *** ******************

private void AddFileGroup(frmMyForm f)

{

SQLMy.SQLServer MySQLServerName = new SQLMy.SQLServer();

SQLMy.Database MyDBDbName = new SQLMy.Database();

SQLMy.FileGroup MyDBDataGroup = new SQLMy .FileGroup();

SQLMy.DBFile MyDBDataFile = new SQLMy.DBFile();

try

{

MySQLServerName.Connect

myGetConfigData.OlapServerName *,myGetConfigData.Ol apUserLogin *,myGetConfigData.OlapUserPassw * ord);


MyDBDbName.Name =

myConnectionData.OlapDatabaseN * ame.ToString()。Trim();

MyDBDataGroup.Name =" DBDataGroup";

MyDBDbName.FileGroups.Add(MyDBDataGroup );

MyDBDataFile.Name =& ; DBData";

MyDBDataFile.PhysicalName =

myConnectionData.OlapDBDataPat * h.ToString()。Trim()+ @" \DBData.ndf";

MyDBDataFile.Size = 50;

MyDBDataFile.MaximumSize = -1;

MyDBDataFile.FileGrowth = 5;

MyDBDataFile.FileGrowthType = 0;

MyDBDataFile.PrimaryFile = false;

MyDBDbName.FileGroups.Item(" DB * DataGroup")。DBFiles .Ad(MyDBDataFile);


this.Close();

MySQLServerName.DisConnect();

}

catch(例外e)

{

MessageBox.Show(e.Message);


}

终于

{

MySQLServerName.DisConnect();


}

}

********************************************** **** ******************


注意:myGetConfigData:这是一个读取
来自XML文件的数据库连接。这个课程已经过广泛测试

并且数据值被填充到变量中。


我将不胜感激任何人都可以提供的任何帮助我。


问候,TFD。

Greetings All, I was hoping that someone might be able to shed some
light on this issue. I am trying to add a FileGroup/Datafile to an
existing SQL database. The code below compile and it runs in .NET
Studio, however nothing happens? The form closes, no error messages
are thrown, there is no sign of any type of error taking place. The
end result (assuming the code is correct) is tha there should be a new
FileGroup with a datafile in it, here is the code:
************************************************** ******************
private void AddFileGroup(frmMyForm f)
{
SQLMy.SQLServer MySQLServerName = new SQLMy.SQLServer();
SQLMy.Database MyDBDbName = new SQLMy.Database();
SQLMy.FileGroup MyDBDataGroup = new SQLMy.FileGroup();
SQLMy.DBFile MyDBDataFile = new SQLMy.DBFile();
try
{
MySQLServerName.Connect
myGetConfigData.OlapServerName*,myGetConfigData.Ol apUserLogin*,myGetConfigData.OlapUserPassw*ord);

MyDBDbName.Name =
myConnectionData.OlapDatabaseN*ame.ToString().Trim ();
MyDBDataGroup.Name = "DBDataGroup";
MyDBDbName.FileGroups.Add (MyDBDataGroup);
MyDBDataFile.Name = "DBData";
MyDBDataFile.PhysicalName =
myConnectionData.OlapDBDataPat*h.ToString().Trim() + @"\DBData.ndf";
MyDBDataFile.Size = 50;
MyDBDataFile.MaximumSize = -1;
MyDBDataFile.FileGrowth = 5;
MyDBDataFile.FileGrowthType = 0;
MyDBDataFile.PrimaryFile = false;
MyDBDbName.FileGroups.Item("DB*DataGroup").DBFiles .Ad (MyDBDataFile);

this.Close();
MySQLServerName.DisConnect();
}
catch (Exception e)
{
MessageBox.Show(e.Message);

}
finally
{
MySQLServerName.DisConnect();

}
}
************************************************** ******************

Note: myGetConfigData: This is a class that reads in the values for the
db connection from an XML file. This class has been tested extensively
and the data values are being populated into the variables.

I would appreciate any help that anyone might be able to provide to me.

Regards, TFD.

推荐答案






鉴于程序的名称,我可能是你未通过许可

检查。你联系的用户有什么特权呢?


为什么你不是一个例外,我不知道,但是DMO可能

沟通其他方式的错误。 (我自己也不认识DMO。)


-

Erland Sommarskog,SQL Server MVP,


SQL Server SP3的联机书籍


这篇关于C#,SQL-DMO,添加文件组问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 00:34