Friday, March 23, 2012
Please explain automatic identity range management
MS SQL Server 2005 RTM. Could anyone please point me to a good source
describing how the automatic identity range management works for merge
repliaction or explain it? In particular, how the options of
Publisher/Subscriber identity range size in Managemen Studio work,
preferrably with examples. I use merge replication between Express and
Standart editions and non-overlapping partitions. Having read some
documentation on this subject I came to conclusions, which contradict the way
everything actually works. For example, if i have an empty table with an
identity column, and I define Publisher identity range size 20000 and
Subscriber identity range size 20000, I expect that the first 20k rows on
Publisher will have identities 1-20000, but the first subscriber will get
ranges 20001 - 40000 and 40001 - 60000. What I get is pretty much different
from that. Although no records were inserted into the table at the Publisher
the first Subscriber starts numbering at 160022, the second - at 80002 and so
on. What's going on?
-- Many thanks, Oskar
Basically there is a 100% buffer in the ranges to prevent the ranges from
being blown between syncs. So the first range is 20,001-40,000 (but with the
buffer it really is 20,001 to 60,000) and the second range is 80,0001 to
100,000 (but with the buffer it is 80,000 to 120,000). It further more seems
like there is a third subscriber somewhere where owns the range from 120,001
to 140,000 (but with the buffer it is 120,001 to 160,000), and then you are
looking at a 4th subscriber which is from 160,001 to 180,000 (but with the
buffer it is from 160,001 to 200,000).
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Oskar" <Oskar@.discussions.microsoft.com> wrote in message
news:BB90CCE0-55E0-4C39-9F8E-5E13DC4FFD2F@.microsoft.com...
> Hi,
> MS SQL Server 2005 RTM. Could anyone please point me to a good source
> describing how the automatic identity range management works for merge
> repliaction or explain it? In particular, how the options of
> Publisher/Subscriber identity range size in Managemen Studio work,
> preferrably with examples. I use merge replication between Express and
> Standart editions and non-overlapping partitions. Having read some
> documentation on this subject I came to conclusions, which contradict the
> way
> everything actually works. For example, if i have an empty table with an
> identity column, and I define Publisher identity range size 20000 and
> Subscriber identity range size 20000, I expect that the first 20k rows on
> Publisher will have identities 1-20000, but the first subscriber will get
> ranges 20001 - 40000 and 40001 - 60000. What I get is pretty much
> different
> from that. Although no records were inserted into the table at the
> Publisher
> the first Subscriber starts numbering at 160022, the second - at 80002 and
> so
> on. What's going on?
> -- Many thanks, Oskar
>
|||Thanks Hilary. In fact I found the answer to my question almost myself. Thing
is that MS SQL Server 2005 keeps track of every identity range it has ever
assigned to a subscriber at each reinitialization. Each time a subscriber is
initialized, new identity range is assigned to it and no longer can be used
by other subscribers or the same subscriber if it needs to be reinitialized.
So this explains, why identity ranges didn't start at values I expected.
-- Thanks, Oskar.
"Hilary Cotter" wrote:
> Basically there is a 100% buffer in the ranges to prevent the ranges from
> being blown between syncs. So the first range is 20,001-40,000 (but with the
> buffer it really is 20,001 to 60,000) and the second range is 80,0001 to
> 100,000 (but with the buffer it is 80,000 to 120,000). It further more seems
> like there is a third subscriber somewhere where owns the range from 120,001
> to 140,000 (but with the buffer it is 120,001 to 160,000), and then you are
> looking at a 4th subscriber which is from 160,001 to 180,000 (but with the
> buffer it is from 160,001 to 200,000).
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
>
> "Oskar" <Oskar@.discussions.microsoft.com> wrote in message
> news:BB90CCE0-55E0-4C39-9F8E-5E13DC4FFD2F@.microsoft.com...
>
>
Wednesday, March 21, 2012
Please can someone point out whats wrong with my code
Hi,
I have code on a page to update one table and insert info into another, but I cant make it work. I am new to coding and i think there are many mistakes. Please can someone pick out a few that need to be changed for the page to work.
Code:
private bool ExecuteUpdate(int quantity)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "ConnectionString";
con.Open();
SqlCommand command = new SqlCommand();
command.Connection = con;
TextBox TextBox1 = (TextBox)FormView1.FindControl("TextBox1");
Label labname = (Label)FormView1.FindControl("Label3");
Label labid = (Label)FormView1.FindControl("Label13");
command.CommandText = "UPDATE Items SET Quantityavailable WHERE productID='@.productID' = " + TextBox1.Text +
command.ExecuteNonQuery();
return true;
con.Close();
}
private bool ExecuteInsert(String quantity)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "ConnectionString";
con.Open();
SqlCommand command = new SqlCommand();
command.Connection = con;
TextBox TextBox1 = (TextBox)FormView1.FindControl("TextBox1");
Label labname = (Label)FormView1.FindControl("Label3");
Label labid = (Label)FormView1.FindControl("Label13");
command.CommandText = "INSERT Transactions SET Usersname = @.UserName" +
"; INSERT Transactions SET Itemid WHERE productID='@.productID' = @.productID; INSERT Transactions SET itemname = @.Itemsname" +
"; INSERT Transactions SET Date WHERE productID='@.productID' = " + DateTime.Now.ToString() +
"; INSERT Transactions SET Qty WHERE productID='@.productID' = " + TextBox1.Text;
command.Parameters.Add("@.UserName", System.Web.HttpContext.Current.User.Identity.Name);
command.Parameters.Add("@.Itemsname", labname.Text);
command.Parameters.Add("@.productID", labid.Text);
command.ExecuteNonQuery();
return true;
con.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox TextBox1 = FormView1.FindControl("TextBox1") as TextBox;
ExecuteUpdate(Int32.Parse(TextBox1.Text) );
ExecuteInsert(Int32.Parse);
}
Current error message is:
The best overloaded method match for 'detailproview.ExecuteInsert(string)' has some invalid arguments
to
Line 74: ExecuteInsert(Int32.Parse);
Thanks if someone can help!
Jon
Hi,
The best way for you to see why it is not working is to debug your code and check the values in the object using Immediate window or pointing the mounse on the objects after value is assigned.
Maybe you are not getting the id that you are using in the WHERE lause of your update statement. Make sure you are getting valid id and that it exists in database.
Finally you are calling return true before closing the connection, first close the connection than return a value.
|||
Int32.Parse is a method and you need to pass in an argument to it, the one string which you want to conevrt to an int, like you are doing it here:
ExecuteUpdate(Int32.Parse(TextBox1.Text) );
Hope this helps,
Vivek
|||Hi,
Thanks both great to help me iron out bugs.
I will put up a new post with the latest set of error messages!
Cheers
Jon