Showing posts with label smo. Show all posts
Showing posts with label smo. 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