Showing posts with label sample. Show all posts
Showing posts with label sample. Show all posts

Monday, March 12, 2012

Is there something similar to SQL 2005 row_number() in sql mobile?

Hello,

I am wondering if somone could provide me with a sample SELECT for an
auto number query. For example I have a table called People with two columns first_name, and last_name. There isn't a unique id to correspond with the table but would like to dynamically make one during the return of the query.

I know this is possible in the full version of sql 2005 using

SELECT ROW_NUMBER() OVER (ORDER BY last_name), first_name, last_name from People

But within sql mobile is there a way?
So if there was 5 rows in the table it would return

1 John Alpha
2 John Beta
3 John Cat
4 John Delta
5 John Echo

John

No SQL Server Mobile/Everywhere Edition does not support Row_Number() and there is no similar function too :(

Thanks,

Laxmi

Is there merge monitor sample in vb.net?

Hello,

We are a vb.net shop and while some of us know a little C# it's not enough. Is there a sample solution for the monitoring of replication in vb.net? I know about the sales one but it's in c#. Thanks.

Please refer to the Books On line link

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/repref9/html/b323da02-fadf-443c-8ba7-0cc050250e2d.htm

which will point to every replication step through RMO programming and sample code is written in VB, C#, C++, J#, etc.

Thanks

|||

Yunjing,

Thanks for the response. Unfortunetly I am rather new to raiseevents. Is there a way someone could convert this to vb.net so I can try and understand it? I am basically looking for a progress bar and text output during the sync progress in vb.net as the SalesOrder sample does in c#. Here is what I have in vb.net but am not sure if it's correct. I also have an error when trying to call the agent.status. I got snippets from the salesorder sample c# solution

Public Delegate Sub SyncWhenConnectedStatus(ByVal sender As Object, ByVal eventArgs As StatusEventArgs)
Public Event Status As SyncWhenConnectedStatus

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
...other code...
Dim subscription As MergePullSubscription
Dim agent As MergeSynchronizationAgent
...other code...
agent.Status += New AgentCore.StatusEventHandler(AddressOf Sync_Status)

**cannot build

**Error 1 'Public Event Status(sender As Object, e As Microsoft.SqlServer.Replication.StatusEventArgs)' is an event, and cannot be called Directly. Use a 'RaiseEvent' statement to raise an event.

agent.Synchronize()
end sub

**Not sure if I am doing this correct either

Private Sub Sync_Status(ByVal sender As Object, ByVal e As StatusEventArgs)
' Update the Synchronization Status form.
txtOutput.AppendText(e.Message.ToString() + Environment.NewLine)

' Call the Status event to update the main form
' if sync when connected is used.
RaiseEvent Status(sender, e)
'If Not Status Is Nothing Then
' RaiseEvent Status(sender, e)
'End If
Application.DoEvents()
End Sub

Friday, February 24, 2012

Is there any sample code which creates login and user of one database using SMO?

Dear All

Is there any sample code which creates login and user for database using SMO?I cannot find any C# sample code can do this.

Any help would be appreciated:)

Here's a sample, you can build from it to allow for creation of group or other login types, etc.

Set up connection to server and database:

_srv = new Server(@."MySqlServer\Instancename");

_dbname = @."MyDatabase";

_db = _srv.Databases[ DBName];

Login lgn = new Login(_srv, @."domain\username");

lgn.DefaultDatabase = _dbname;

lgn.LoginType = LoginType.WindowsUser;

lgn.Create();

User usr = new User(_db, @."MyUserName");

usr.Login = loginId;

usr.Create();

--Stan

|||

My bad, I was reading this topic in reverse date order and just noticed that another thread asked a similar question and got basically the same response.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=195387&SiteID=1

|||

Hi,

sorry the same day you posted the question I wrote quick application, I imported that in a q&d Winform solution, which might help you to see the way to do it:

http://www.sqlserver2005.de/SharedFiles/UserMappingwithSMO.zip

HTH; Jens Suessmeyer.


http://www.sqlserver2005.de

Is there any sample code to demo the SSB send messages with same sql instance?

Is there any sample code to demo the SSB send messages with same sql instance?

my case is very simple:

I want write a stored procedure to send a xml to another database. The stored procedure is called by tables triggers when some data is changed under the specific conditions.

this should be exactly what you need:

http://www.sqlteam.com/article/centralized-asynchronous-auditing-with-service-broker

Is there any known issue with Service Broker on Vista

When I run the ServiceBroker Hello, World sample on SQL Server Standard SP2
or SQL Server Express on Vista, I observe that no message is ever entered in
any queue. When I run the same sample on Windows Server 2008 Enterprise, the
sample behaves as it should.
So, is there any known issue with Service Broker on Vista, or does Service
Broker have some dependency on services or O/S settings that I have missed.
Answering my own question:
Vista proved not to be the significant variable in the problem. The
troubleshooting documentation led me to this query:
select * from sys.transmission_queue
... which yielded this result:
An exception occurred while enqueueing a message in the target queue. Error:
15517, State: 1. Cannot execute as the database principal because the
principal "dbo" does not exist, this type of principal cannot be
impersonated, or you do not have permission.
... which is an error fixed by executing:
EXEC sp_changedbowner 'sa'
"Craig McMurtry" wrote:

> When I run the ServiceBroker Hello, World sample on SQL Server Standard SP2
> or SQL Server Express on Vista, I observe that no message is ever entered in
> any queue. When I run the same sample on Windows Server 2008 Enterprise, the
> sample behaves as it should.
> So, is there any known issue with Service Broker on Vista, or does Service
> Broker have some dependency on services or O/S settings that I have missed.

Is there any known issue with Service Broker on Vista

When I run the ServiceBroker Hello, World sample on SQL Server Standard SP2
or SQL Server Express on Vista, I observe that no message is ever entered in
any queue. When I run the same sample on Windows Server 2008 Enterprise, the
sample behaves as it should.
So, is there any known issue with Service Broker on Vista, or does Service
Broker have some dependency on services or O/S settings that I have missed.Answering my own question:
Vista proved not to be the significant variable in the problem. The
troubleshooting documentation led me to this query:
select * from sys.transmission_queue
... which yielded this result:
An exception occurred while enqueueing a message in the target queue. Error:
15517, State: 1. Cannot execute as the database principal because the
principal "dbo" does not exist, this type of principal cannot be
impersonated, or you do not have permission.
... which is an error fixed by executing:
EXEC sp_changedbowner 'sa'
"Craig McMurtry" wrote:
> When I run the ServiceBroker Hello, World sample on SQL Server Standard SP2
> or SQL Server Express on Vista, I observe that no message is ever entered in
> any queue. When I run the same sample on Windows Server 2008 Enterprise, the
> sample behaves as it should.
> So, is there any known issue with Service Broker on Vista, or does Service
> Broker have some dependency on services or O/S settings that I have missed.