Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Sunday, March 11, 2012

Creating a Mobile Application with SQL Server Mobile - FIX

This is a great tutorial and it's a shame one of the more important steps was missed.

In the “Create the snapshot user” section you you find the steps to create the snapshot_agent account. Then in the “Create the snapshot folder” section you find the share and folder permissions. However, at no point do the instructions advise you about adding the snapshot_agent to the SQL Server Logins. The result is that agent cannot perform the initial snapshot but you won't find this out until 50 steps later after Step 10 in the section “Create a new subscription".

To get back on track, openthe Object Explorer's Security section and add the snapshot_agent to your logins. Then using the "User Mappings", set an appropriate level for the SQLMobile database role. Once completed you then need to run the agent.

Right-click the SQLMobile publication you created and select "View Snapshot Agent status". From that dialog you can select "Start" to run the agent. When it completes, you can return to the tutorial section "Create a new subscription" and continue with the tutorial.

that's one way to do it and thanks for pointing out the omission. a more common approach is to make sure the account that the snapshot agent runs as is granted permissions on the publication, the database engine, and the database.

Darren

|||

Darren,

In order to grant permissions on the database engine you need to create the login. And just granting permission on the database engine, database and the publication doesn't seem do it. You still need to asign a "Server Role" to the login. My first guess was "processadmin"; however, I tried a number of different combinations without success. Only when I set the snaphot-agent to the role of "sysadmin" was I able to get the agent to complete the process of creating the initial snapshot.

|||

that's true if the account you chose to run SQL Agent as isn't already recognized in the sysadmin role as a SQL Server login. for the average developer trying to get merge repl working the first time, SQL Server and IIS are both running on the machine that the device is connected to via ActiveSync. what I was trying to say in my last post is, whatever account you log on to you machine with, as long as it is an Administrator account, this is a good account to run the SQL Agent under. That makes the permissions issues easier to configure on SQL Server as you only have to grant that login appropriate permissions on the pub and the db. Of course you also grant permissions to the IUSR_{your machine name} account if using anonymous auth.

in a production environment, some other account should be used and as you correctly noted, this account needs to either be sysadmin on SQL Server or be granted db_reader and db_writer on the pub and published database. typically, IIS and SQL Server are on separate boxes in this scenario and a domain account is used that both machines can recognize.

Darren

|||

It is less than practical to use the "sysadmin" role in this instance. Review of the documentation shows that the minimum permissions for a "pull subscription" require the login to be associated with a user in the distribution database. At minimum be a member of the db_owner fixed database role in the distribution database.

So I have now removed the sysadmin role from the computername\snapshot_agent and added it as a user in the distribution database with the db_owner role. These permissions allow the agent to run the replication snapshot job.

Now, I have no indication that others are able to run this tutorial without specifically setting the above permission. If they are, then perhaps some other settings related to the wizards or replication itself are necessary.

The real point here is that given a tutorial which identifies each step in setting up replication (including specific names and permisions) should work according to the names/permissions identified. So lets fix the omission and move on.

Note: specific infornation is available at http://msdn2.microsoft.com/en-us/library/ms151868(d=ide).aspx


Friday, February 24, 2012

Creating a Connection

I am trying to connect to a database on an MS Sql server, I typed the code exactly like what is shown in the tutorial and I keep getting an error... (Error in line 6)

Line 4: Dim oODBCConnection As OdbcConnection
Line 5: Dim sConnString As String = _
Line 6: "Driver={SQL Server};" &_
Line 7: "Server=209.151.130.8;" &_
Line 8: "Database=blah;" &_
...(Error in line 6)

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30203: Identifier expected.First off - I'd say you're going in the wrong direction, since it looks as if you're trying to connect with a SQL server - -
ASP.Net has a namespace that talks directly to SQL Server...
it should look more like the info in :
Database Connect and Display Samples

Which tutorial are you reading?|||I've been using Classic ASP untill now, I'm moving on up to .NET...

I'm looking for a very simple way to retreave some data from a database and display it using of of the data web controls..

The part that I'm having trouble with is comunicating with the server (creating a connection)..

On The Side:
I've read about placing the connection string in the AppSettings section in web.config, but this isn't going to work in my case because I am only working with a single aspx file... Am I correct in saying that this way won't work because I'm using only one aspx file..|||Ps: I changed the ip, and user name for security reasons...

<% @.Import Namespace="System.Data.SqlClient" %>
<% @.Import Namespace="System.Data" %>
<script language="vb" runat="server" debug="true"
Sub Page_Load(Source as Object, E as EventArgs)
Dim strConn as string = "server=555.555.11.11;uid=test;pwd=test1;database=webland"
Dim MySQL as string = "Select pl_username From Users"
Dim MyConn as New SQLConnection(strConn)
Dim ds as DataSet=New DataSet()
Dim Cmd as New SQLDataAdapter(MySQL,MyConn)
Cmd.Fill(ds,"Customers")
myDataList.Datasource=ds.Tables("users").DefaultView
myDataList.DataBind()
End Sub

</script
<asp:DataList runat="server" id="myDataList"
Width="85%" Border="1"
HorizontalAlign="Center"
Font-Name="Verdana" CellPadding="4"
Font-Size="10pt"
RepeatColumns="5" >
<ItemTemplate>
Question:<br />
<%# DataBinder.Eval(Container.DataItem, "pl_username") %>
</ItemTemplate>
</asp:DataList
ERROR:
Cannot open database requested in login 'webland'. Login fails. Login failed for user 'test'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open database requested in login 'webland'. Login fails. Login failed for user 'test'.

BUT:
I bleave that my user name information that I provided is correct..I think taht something else is causing the error, but i'm not getting the correct error message?|||It is very possible that wherever this database resides, that they are not using the standard sql port 1433. A lot of places are doing this now for security by obscurity reasons. Anyway, if you don't know for sure, I would contact the people who host your website and make sure that you have the right port. If it is a different port just add a comma and the port number after the server address. For example if you find out that the port number is 1435, then instead of this:

Dim strConn as string="server=555.555.11.11;uid=test;pwd=test1;database=webland"

try this:

Dim strConn as string="server=555.555.11.11,1435;uid=test;pwd=test1;database=webland"