C#,SQL-DMO,添加文件组问题。 [英] C#, SQL-DMO, Add FileGroup Issue.

查看:51
本文介绍了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:这是一个读取<的值的类br />
来自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.

推荐答案




您是否运行过探查器以查看它在数据库端的作用?


John


" LineVoltageHalogen" < TR **************** @ yahoo.com>在消息中写道

新闻:11 ********************** @ z14g2000cwz.googlegr oups.com ...

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

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

现有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:这是一个读取<的值的类br />
来自XML文件的数据库连接。这个课程已经过广泛测试

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


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


问候,TFD。
Hi

Have you run profiler to see what it is doing at the database end?

John

"LineVoltageHalogen" <tr****************@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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.


我使用Lumigents Entegra追踪行动。表中只有一个电话

:master.dbo.spt_values,这里是完整的文字:


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

- sp_MSdbuserpriv

选择@@版本,N''login_id''= convert(int,suser_sid()),N ''pagesize''

= v.low,N''highbit''= v2.low,N''highbyte''= v3.low,

N' 'casesens''=(大概是(N''A'!= N''a'')然后1其他0结束),@@ spid,

convert(sysname,serverproperty(N ''servername'')),

is_srvrolemember(N''sysadmin''),@ dbrole,

N''InstanceName''= convert(sysname,serverproperty( N''instancename'')),

N''PID''=转换(int,serverproperty(N''processid''))
来自master的
.. spt_values v,master..spt_values v2,master..spt_values v3

其中v.number = 1且v.type = N 'E''和v2.number = 2

和v2.type = N''E''和v3.number = 3和v3.type = N''E''

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


因此,它看起来像正在建立连接但是命令

创建文件组/数据文件永远不会被发出?


TFD

I used Lumigents Entegra to trace the action. There is only one call
to the table: master.dbo.spt_values, here is the complete text:

************************************************** ************************************************** ******************
-- sp_MSdbuserpriv
select @@version, N''login_id'' = convert(int, suser_sid()), N''pagesize''
= v.low, N''highbit'' = v2.low, N''highbyte'' = v3.low,
N''casesens'' = (case when (N''A'' != N''a'') then 1 else 0 end), @@spid,
convert(sysname, serverproperty(N''servername'')),
is_srvrolemember(N''sysadmin''), @dbrole,
N''InstanceName'' = convert(sysname, serverproperty(N''instancename'')),
N''PID'' = convert(int, serverproperty(N''processid''))
from master..spt_values v,master..spt_values v2,master..spt_values v3
where v.number=1 and v.type=N''E'' and v2.number=2
and v2.type=N''E'' and v3.number=3 and v3.type=N''E''
************************************************** ************************************************** *******************

So, it looks like the connection is being made but the command to
create the filegroup/datafile is never being issued?

TFD


LineVoltageHalogen (tr****************@yahoo.com)写道:
LineVoltageHalogen (tr****************@yahoo.com) writes:
我使用Lumigents Entegra来追踪行动。表格只有一个电话:master.dbo.spt_values,这里是完整的文字:

- sp_MSdbuserpriv
I used Lumigents Entegra to trace the action. There is only one call
to the table: master.dbo.spt_values, here is the complete text:
-- sp_MSdbuserpriv




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

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


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

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


-

Erland Sommarskog,SQL Server MVP, es **** @ sommarskog.se


SQL Server SP3的联机书籍
http://www.microsoft.com/sql/techinf...2000/ books.asp


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆