Showing posts with label object. Show all posts
Showing posts with label object. Show all posts

Monday, March 26, 2012

How Can I call SQL Server SMO Objects in VC6 or VB6

How Can I call SQL Server SMO Objects in VC6 or VB6

Hi

I want to use SQL SMO (SQL Management Object .Net Library) in VC 6.0 and VB.6.0

I don’t want to use SQL DMO (COM component)

I tried to make COM callable wrapper (CCW) for SMO using the following command line execution.

RegAsm.exe /tlb:MicrosoftSqlServerSmoTest.tlb Microsoft.SqlServer.Smo.dll

After executing the command line RegAsm.exe, I got the following output.

Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.42

Copyright (C) Microsoft Corporation 1998-2004. All rights reserved.

Types registered successfully

Type library exporter warning processing 'Microsoft.SqlServer.Management.Smo.Bac

kupDeviceList, Microsoft.SqlServer.Smo'. Warning: Type library exporter encounte

red a type that derives from a generic class and is not marked as [ClassInterfac

e(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types.

Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exp

osing an explicit interface as the default interface to COM using the ComDefault

Interface attribute.

Assembly exported to 'C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies\Mi

crosoftSqlServerSmoTest.tlb', and the type library was registered successfully

In My VB6 Application I have included the Refrence Microsoft_SqlServer_Smo

Then I tried to call Server Object with parameter shown below.

Dim objServer As Server

Set objServer = new Server(Server_Name)

But compile error occurs in the line Set objServer = new Server(Server_Name)


I have the following queries.

  1. How can I access SMO objects in VC 6 or VB6 applications using any method?

  1. How can I solve the compile error?

  1. How can I avoid the Warning when calling the callable wrapper (CCW)?

4. Is it possible to use parameterized constructors in .net components?

  1. Is it necessary that the GUIDs to all .NET objects so that the appropriate COM required registry entries can be created?

For example :

[Guid("2979DBB0-3371-4841-9B94-B79EAE28B503")]

public class TestInteropSample

{

}

Kindly reply me ,

Thanking you,

Kuttappan.

Hello,

I'm having the same problem. Did you ever find a solution?

thanks,

kelly

|||

SMO is only supported in VB/C#.Net 2005. It requires the .Net 2.0 Framework, which isn't available in VB/VC 6.

Friday, March 23, 2012

How Can I call SQL Server SMO Objects in VC6 or VB6

How Can I call SQL Server SMO Objects in VC6 or VB6

Hi

I want to use SQL SMO (SQL Management Object .Net Library) in VC 6.0 and VB.6.0

I don’t want to use SQL DMO (COM component)

I tried to make COM callable wrapper (CCW) for SMO using the following command line execution.

RegAsm.exe /tlb:MicrosoftSqlServerSmoTest.tlb Microsoft.SqlServer.Smo.dll

After executing the command line RegAsm.exe, I got the following output.

Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.42

Copyright (C) Microsoft Corporation 1998-2004. All rights reserved.

Types registered successfully

Type library exporter warning processing 'Microsoft.SqlServer.Management.Smo.Bac

kupDeviceList, Microsoft.SqlServer.Smo'. Warning: Type library exporter encounte

red a type that derives from a generic class and is not marked as [ClassInterfac

e(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types.

Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exp

osing an explicit interface as the default interface to COM using the ComDefault

Interface attribute.

Assembly exported to 'C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies\Mi

crosoftSqlServerSmoTest.tlb', and the type library was registered successfully

In My VB6 Application I have included the Refrence Microsoft_SqlServer_Smo

Then I tried to call Server Object with parameter shown below.

Dim objServer As Server

Set objServer = new Server(Server_Name)

But compile error occurs in the line Set objServer = new Server(Server_Name)


I have the following queries.

  1. How can I access SMO objects in VC 6 or VB6 applications using any method?

  1. How can I solve the compile error?

  1. How can I avoid the Warning when calling the callable wrapper (CCW)?

4. Is it possible to use parameterized constructors in .net components?

  1. Is it necessary that the GUIDs to all .NET objects so that the appropriate COM required registry entries can be created?

For example :

[Guid("2979DBB0-3371-4841-9B94-B79EAE28B503")]

public class TestInteropSample

{

}

Kindly reply me ,

Thanking you,

Kuttappan.

Hello,

I'm having the same problem. Did you ever find a solution?

thanks,

kelly

|||

SMO is only supported in VB/C#.Net 2005. It requires the .Net 2.0 Framework, which isn't available in VB/VC 6.

How Can I call SQL Server SMO Objects in VC6 or VB6

How Can I call SQL Server SMO Objects in VC6 or VB6

Hi

I want to use SQL SMO (SQL Management Object .Net Library) in VC 6.0 and VB.6.0

I don’t want to use SQL DMO (COM component)

I tried to make COM callable wrapper (CCW) for SMO using the following command line execution.

RegAsm.exe /tlb:MicrosoftSqlServerSmoTest.tlb Microsoft.SqlServer.Smo.dll

After executing the command line RegAsm.exe, I got the following output.

Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.42

Copyright (C) Microsoft Corporation 1998-2004. All rights reserved.

Types registered successfully

Type library exporter warning processing 'Microsoft.SqlServer.Management.Smo.Bac

kupDeviceList, Microsoft.SqlServer.Smo'. Warning: Type library exporter encounte

red a type that derives from a generic class and is not marked as [ClassInterfac

e(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types.

Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exp

osing an explicit interface as the default interface to COM using the ComDefault

Interface attribute.

Assembly exported to 'C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies\Mi

crosoftSqlServerSmoTest.tlb', and the type library was registered successfully

In My VB6 Application I have included the Refrence Microsoft_SqlServer_Smo

Then I tried to call Server Object with parameter shown below.

Dim objServer As Server

Set objServer = new Server(Server_Name)

But compile error occurs in the line Set objServer = new Server(Server_Name)


I have the following queries.

  1. How can I access SMO objects in VC 6 or VB6 applications using any method?

  1. How can I solve the compile error?

  1. How can I avoid the Warning when calling the callable wrapper (CCW)?

4. Is it possible to use parameterized constructors in .net components?

  1. Is it necessary that the GUIDs to all .NET objects so that the appropriate COM required registry entries can be created?

For example :

[Guid("2979DBB0-3371-4841-9B94-B79EAE28B503")]

public class TestInteropSample

{

}

Kindly reply me ,

Thanking you,

Kuttappan.

Hello,

I'm having the same problem. Did you ever find a solution?

thanks,

kelly

|||

SMO is only supported in VB/C#.Net 2005. It requires the .Net 2.0 Framework, which isn't available in VB/VC 6.

Monday, March 12, 2012

How calculate SMO.Transfer progress?

I have work code who transfer database using SMO.Transfer object.

This code start my transfer and subscribe my event handlers. I have such problem: DiscoveryProgress - does not approach. Maybe need use additional options?

m_tr.ScriptingError += new ScriptingErrorEventHandler(m_tr_ScriptingError);
m_tr.ScriptingProgress += new ProgressReportEventHandler(m_tr_ScriptingProgress);

m_tr.DiscoveryProgress += new ProgressReportEventHandler(m_tr_DiscoveryProgress);
m_tr.DataTransferEvent += new DataTransferEventHandler(m_tr_DataTransferEvent);

m_script = m_tr.ScriptTransfer();
m_tr.TransferData();

Sergey,

You can define your event handlers like this:

public static void DataTransferHandler(object sender, DataTransferEventArgs e)
{
Console.WriteLine(e.DataTransferEventType.ToString() + " : " + e.Message);
}

public static void ProgressEventHandler(object sender, ProgressReportEventArgs args)
{
Console.Write("Progress {0} of {1} . . . {2} \n", args.TotalCount, args.Total, args.Current);
}

public static void ScriptingProgressEventHandler(object sender, ProgressReportEventArgs args)
{
Console.Write("Progress {0} of {1} . . . {2} \n", args.TotalCount, args.Total, args.Current);
}

Then set up your events like this:

trans.DiscoveryProgress += new ProgressReportEventHandler(ProgressEventHandler);

trans.ScriptingProgress += new ProgressReportEventHandler(ScriptingProgressEventHandler);

trans.DataTransferEvent += new DataTransferEventHandler(DataTransferHandler);

By the way, you don't need to call ScriptTransfer before calling TransferData. ScriptTransfer returns TSQL script in a StringCollection, which you are not using.

Artur Laksberg

SQL Server Team

|||Hi Artur,
I did this as you wrote. I only use the scripting progress and the discover progress for my app. The scripting event is raised, and my handler gets it, but the totals and subtotals all remain at value of 1. The discovery event is either never raised or something is wrong on my side as my handler is never called.
Do you know what else I can try? Is this a known issue?
Regards
Japie Teunissen
|||

Japie,

You are right: we seem to have a few problems here. Total shows right values for Scripting, but Transfer uses Scripting to transfer objects one at a time, hence "1 out of 1" you see in the event handler. Sort of makes sense but not useful at all.

Discover event is only raised when you call Script with a list of URNs, which most people don't. Again, confusing and not very useful.

I'll file a bug to clean this up.

Thanks to you and Sergey for pointing this out.

Artur Laksberg
SQL Server Team
Microsoft

How calculate SMO.Transfer progress?

I have work code who transfer database using SMO.Transfer object.

This code start my transfer and subscribe my event handlers. I have such problem: DiscoveryProgress - does not approach. Maybe need use additional options?

m_tr.ScriptingError += new ScriptingErrorEventHandler(m_tr_ScriptingError);
m_tr.ScriptingProgress += new ProgressReportEventHandler(m_tr_ScriptingProgress);

m_tr.DiscoveryProgress += new ProgressReportEventHandler(m_tr_DiscoveryProgress);
m_tr.DataTransferEvent += new DataTransferEventHandler(m_tr_DataTransferEvent);

m_script = m_tr.ScriptTransfer();
m_tr.TransferData();

Sergey,

You can define your event handlers like this:

public static void DataTransferHandler(object sender, DataTransferEventArgs e)
{
Console.WriteLine(e.DataTransferEventType.ToString() + " : " + e.Message);
}

public static void ProgressEventHandler(object sender, ProgressReportEventArgs args)
{
Console.Write("Progress {0} of {1} . . . {2} \n", args.TotalCount, args.Total, args.Current);
}

public static void ScriptingProgressEventHandler(object sender, ProgressReportEventArgs args)
{
Console.Write("Progress {0} of {1} . . . {2} \n", args.TotalCount, args.Total, args.Current);
}

Then set up your events like this:

trans.DiscoveryProgress += new ProgressReportEventHandler(ProgressEventHandler);

trans.ScriptingProgress += new ProgressReportEventHandler(ScriptingProgressEventHandler);

trans.DataTransferEvent += new DataTransferEventHandler(DataTransferHandler);

By the way, you don't need to call ScriptTransfer before calling TransferData. ScriptTransfer returns TSQL script in a StringCollection, which you are not using.

Artur Laksberg

SQL Server Team

|||Hi Artur,
I did this as you wrote. I only use the scripting progress and the discover progress for my app. The scripting event is raised, and my handler gets it, but the totals and subtotals all remain at value of 1. The discovery event is either never raised or something is wrong on my side as my handler is never called.
Do you know what else I can try? Is this a known issue?
Regards
Japie Teunissen
|||

Japie,

You are right: we seem to have a few problems here. Total shows right values for Scripting, but Transfer uses Scripting to transfer objects one at a time, hence "1 out of 1" you see in the event handler. Sort of makes sense but not useful at all.

Discover event is only raised when you call Script with a list of URNs, which most people don't. Again, confusing and not very useful.

I'll file a bug to clean this up.

Thanks to you and Sergey for pointing this out.

Artur Laksberg
SQL Server Team
Microsoft

Friday, March 9, 2012

How Analysis Services Server select the storage location for any object of within an analysis se

Hi, all experts here,

Thank you very much for your kind attention.

Could please any of you kindly advise me how can we find the storage locations of partitions of a cube from its code? (.xml file). Thanks a lot in advance and I am looking forward to hearing from you shortly for your advices and help.

With best regards,

Yours sincerely,

Hi, all experts here,

I am just a bit confused about the storage location of the objects of an analysis services database. It does not seem like it stores all the objects within the same folder the very first time when we created the analysis services database project from BI studio, since I created the project in a folder which is different from the folder where the dimensions files of a cube are stored? How it works? Please shed me some light on it and I am really looking forward to hearing from you for your kind advices.

Thanks a lot in advance.

With best regards,

Yours sincerely,

|||

The folder created by the BIDS project simply contains metadata files. When you deploy, process, or what not in BIDS, those metadata files are used to compile scripts that are submitted to Analysis Services. Analysis Services constructs its objects within its data folder. The root data folder can be found by openning SQL Server Management Studio, connecting to an instance of SSAS, right-clicking the SSAS instance object, and selecting Properties from the context menu. On the dialog to pops up, look for the DataDir entry.

Bryan

|||

Hi, Bryan,

Thanks for your kind advices.

With best regards,

Yours sincerely,

Sunday, February 19, 2012

HostName and ReinitializeSubscription

Hello all,

I'm having trouble with my Merge Replication setup in regards to changing the HostName property of the SqlCeReplication object. As we all know, if you modify the HostName value, you must then call the ReinitializeSubscription(true) method before calling Synchronize(). Unfortunately, this isn't working for me. Following this sequence of steps consistently results in error messages saying that I need to either call ReinitializeSubscription, or change my HostName back to it's original value. Has anyone ever experienced this problem?

Regards,

Rob Tiffany

Hey Rob,

You are correct, once you specify a HostName value for a subscriber, if you want to change that value later, you must call SqlCeReplication.ReinitializeSubscription(True) followed by .Synchronize() to effectively make the change.

I built an app recently for a large field service scenario where the mobile device can change hands from field worker to field worker. I decided to use the field worker's unique identifier as the value for HostName so that I could replicate only the appropriate data for a given worker to a given SQL Mobile database. If the device changes hands, here is the process of making the change to HostName and reinitializing:

Public Function Synchronize() As Boolean

Dim retVal As Boolean = False

Dim repl As SqlCeReplication = GetReplication()

If repl Is Nothing Then
Return False
End If

Try

If Globals.GetInstance().HostNameChanged Then
repl.ReinitializeSubscription(True)
Globals.GetInstance().HostNameChanged = False
End If

repl.Synchronize()

etc etc etc

If you are doing something similar and getting an error, could you post the details on the error itself and Laxmi and I can look into it? Also, some info on your configuration (assume you are talking about SQL Mobile and SS2005?)

Regards,

Darren

|||

Yeah, that's what I'm doing too. My Sync code blocks looks like the following:

private void replicate(bool reInit)

{

SqlCeReplication repl = new SqlCeReplication();

repl.InternetUrl = Settings1.Default.InternetURL;

repl.InternetLogin = Settings1.Default.InternetLogin;

repl.InternetPassword = Settings1.Default.InternetPassword;

repl.Publisher = Settings1.Default.Publisher;

repl.PublisherDatabase = Settings1.Default.PublisherDatabase;

repl.Publication = Settings1.Default.Publication;

repl.PublisherSecurityMode = SecurityType.NTAuthentication;

repl.SubscriberConnectionString = @."Data Source=" + localFolder + "MyDB.sdf;Password=p@.ssw0rd;";

repl.Subscriber = Settings1.Default.Subscriber;

repl.HostName = txtAgentId.Text;

repl.CompressionLevel = Settings1.Default.CompressionLevel;

repl.ExchangeType = ExchangeType.BiDirectional;

try

{

if (!File.Exists(localFolder + "MyDB.sdf"))

{

repl.AddSubscription(AddOption.CreateDatabase);

}

if (reInit == true)

{

repl.ReinitializeSubscription(true);

}

// Synchronize with SQL Server 2005

repl.Synchronize();

}

finally

{

repl.Dispose();

}

}

If the user changes the HostName, then I pass "true" to the method above to call ReinitializeSubscription(true).

Thanks,

Rob

|||

there is a possible code path in your code where the database does not exist and you (are going to create it using AddOption.CreateDatabase on the first replication), but reinit can also be true - this won't work - you cannot mix CreateDatabase and Reinit in the same call to Synchronize.

Could that be what's happening? What error messages are you getting?

Darren

|||

I don't have the exact error message in front of me now, but is says something like:

Error: Changing the HostName requires a call to ReinitializeSubscription() or change your HostName back to the original value. HostName = 2, Original HostName = 1.

Something like that. Keep in mind that it will even throw this same error when I call ReinitializeSubscription().

To answer your other question, I haven't experienced the possible code path error you described where the database doesn't exist. It should also be known that this is a desktop XP project and not on Windows Mobile. Just in case we have subtle differences or issues between the desktop and handheld dlls. I'm trying to do some load testing and the desktop is the only way to create enough clients.

Rob