Showing posts with label updating. Show all posts
Showing posts with label updating. Show all posts

Thursday, March 8, 2012

Adding parameters during .updating event handler

Not receiving any errors. The update runs perfectly on all fields, except for the added parameter during the sub. I need to change the hidden field's value after parsing out several fields in the form and generating a logfile entry of sorts. This needs to happen after all the form fields are updated, but before the update is executed.

aspx: (relevant parts only...)
<asp:SqlDataSourceID="TicketDetails"runat="server"ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
UpdateCommand="UPDATE Tickets SET TicketSuspense = @.TicketSuspense, TicketPriority = @.TicketPriority, TicketLastUpdated = CURRENT_TIMESTAMP, TicketStatus = 'Assigned', TicketTechnicianNotes = @.TicketTechnicianNotes WHERE (TicketID = @.TicketID)">
<UpdateParameters>
<asp:ParameterName="TicketPriority"Type="String"/>
<asp:ParameterName="TicketSuspense"Type="DateTime"/>
<asp:ParameterName="TicketID"Type="Int32"/>
</UpdateParameters>
</asp:SqlDataSource>

codebehind: (once again, the relevant parts only)
ProtectedSub TicketDetails_Updating(ByVal senderAsObject,ByVal eAs System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)Handles TicketDetails.Updating
TicketTechnicianNotesHiddenField.Value ="some text..."& TicketTechnicianNotesHiddenField.Value
TicketDetails.UpdateParameters.Add(New Parameter("TicketTechnicianNotes", TypeCode.String, TicketTechnicianNotesHiddenField.Value))
EndSub

Thanks,

- Brad

What about this:

ProtectedSub TicketDetails_Updating(ByVal senderAsObject,ByVal eAs System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)Handles TicketDetails.Updating
TicketTechnicianNotesHiddenField.Value ="some text..."& TicketTechnicianNotesHiddenField.Value

e.Command.Parameters("@.TicketTechnicianNotes").Value = TicketTechnicianNotesHiddenField.Value


EndSub

|||

I think that was the only variation I hadn't yet tried. It worked.

I have to ask... what caused the "Add" not to work?

Thanks,

- Brad

|||

"TheSqlDataSource control will also automatically create parameters based on values passed by a data-bound control... "

You can find more information from this link:

http://msdn2.microsoft.com/en-us/library/z72eefad.aspx

Tuesday, March 6, 2012

Adding New Column & updating bulk data in merge replication

Hi,
We have about 50 databases (SQL Server 2000, SP3) which are merge
replicated. We merge replicate about 100 odd tables in each of these
database. We need to add couple of columns in one of our major transaction
table where most insert/updates are being done. This table presently on
average has 5 lacs records.
During testing, we noticed that it takes about 60-80 minutes to add a
column in this table. Considering the # of database we have where the change
need to implemented, we will not be able to plan the upgrade without
production downtime. For upgrade 50 database it will take about 50 hours.
What are the options available in Replication so this can be done quickly
w/o any production downtime.
Adding to this, in one of the column we have added to the transaction table
, we need to update a new value. On testing we found that for 5 lacs records
it takes anyway between 2-3 hours. This takes roughly another 75 hours for
us to do this update after adding the new column in the table. How can this
be speeded up ?
thanks,
Soura
What's a lacs?
Basically there is probably no good solution for this. I would look at doing
a sync. Then creating my publication and then backing it up and restoring it
to all the subscribers and doing a no sync subscription, or I would look at
regenerating a snapshot and distributing it after you have made the column
change.
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
"SouRa" <SouRa@.discussions.microsoft.com> wrote in message
news:A19172BF-E8AC-4BB7-9FED-87EEC5353D89@.microsoft.com...
> Hi,
> We have about 50 databases (SQL Server 2000, SP3) which are merge
> replicated. We merge replicate about 100 odd tables in each of these
> database. We need to add couple of columns in one of our major transaction
> table where most insert/updates are being done. This table presently on
> average has 5 lacs records.
> During testing, we noticed that it takes about 60-80 minutes to add a
> column in this table. Considering the # of database we have where the
> change
> need to implemented, we will not be able to plan the upgrade without
> production downtime. For upgrade 50 database it will take about 50 hours.
> What are the options available in Replication so this can be done quickly
> w/o any production downtime.
> Adding to this, in one of the column we have added to the transaction
> table
> , we need to update a new value. On testing we found that for 5 lacs
> records
> it takes anyway between 2-3 hours. This takes roughly another 75 hours for
> us to do this update after adding the new column in the table. How can
> this
> be speeded up ?
> thanks,
> Soura
|||5 lacs is 500 K or 500 thousand i.e 500,000
lacs is primarily an indian unit of measurment. 1 lac is 0.1 million
"Hilary Cotter" wrote:

> What's a lacs?
> Basically there is probably no good solution for this. I would look at doing
> a sync. Then creating my publication and then backing it up and restoring it
> to all the subscribers and doing a no sync subscription, or I would look at
> regenerating a snapshot and distributing it after you have made the column
> change.
> --
> 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
> "SouRa" <SouRa@.discussions.microsoft.com> wrote in message
> news:A19172BF-E8AC-4BB7-9FED-87EEC5353D89@.microsoft.com...
>
>

Sunday, February 12, 2012

Adding and Updating in same query

Hi all,
I am trying to copy records from table 1 where field 1 is equal to "N" to
table 2. I also want to change field1 to "Y" after the copy or delete the
record, so that the record will not get copied again.
Can this be done?
Thank you,
George
One thing I need to mention: I am trying to accomplish this in the
Transformation
Thanks again.
George
|||> One thing I need to mention: I am trying to accomplish this in the
> Transformation
What is "the Transformation"?
|||Of course you can handle this in multiple ways, e.g. one way would be to use
Y on insert
INSERT INTO table2(field1, pk) SELECT 'Y', pk
FROM table1 t1
LEFT OUTER JOIN table2 t2
ON t1.pk = t2.pk
WHERE t2.pk IS NULL
Or not have a "field1" at all. Assuming you can identify any row in either
table uniquely, and properly identify a duplicate, you can easily use a
similar LEFT JOIN without needing a flag.
Or not have two tables at all. What are you trying to accomplish with two
tables that you can't accomplish with one?
If this isn't helpful, then instead of an ambiguous word problem, please
post DDL, sample data and desired results. See http://www.aspfaq.com/5006
for info.
"George" <George@.discussions.microsoft.com> wrote in message
news:CB84E118-4A8C-43BD-9A22-6C58E98D5461@.microsoft.com...
> Hi all,
> I am trying to copy records from table 1 where field 1 is equal to "N" to
> table 2. I also want to change field1 to "Y" after the copy or delete the
> record, so that the record will not get copied again.
> Can this be done?
> Thank you,
> George
|||Hi George,
INSERT INTO TABLE2 SELECT <FIELDS> FROM TABLE1 WHERE FIELD1='N'
GO
UPDATE TABLE1 SET FIELD1='Y'
GO
Hope this will solve the problem
thanks and regards
Chandra
"George" wrote:

> Hi all,
> I am trying to copy records from table 1 where field 1 is equal to "N" to
> table 2. I also want to change field1 to "Y" after the copy or delete the
> record, so that the record will not get copied again.
> Can this be done?
> Thank you,
> George

Adding and Updating in same query

Hi all,
I am trying to copy records from table 1 where field 1 is equal to "N" to
table 2. I also want to change field1 to "Y" after the copy or delete the
record, so that the record will not get copied again.
Can this be done?
Thank you,
GeorgeOne thing I need to mention: I am trying to accomplish this in the
Transformation
Thanks again.
George|||> One thing I need to mention: I am trying to accomplish this in the
> Transformation
What is "the Transformation"?|||Of course you can handle this in multiple ways, e.g. one way would be to use
Y on insert
INSERT INTO table2(field1, pk) SELECT 'Y', pk
FROM table1 t1
LEFT OUTER JOIN table2 t2
ON t1.pk = t2.pk
WHERE t2.pk IS NULL
Or not have a "field1" at all. Assuming you can identify any row in either
table uniquely, and properly identify a duplicate, you can easily use a
similar LEFT JOIN without needing a flag.
Or not have two tables at all. What are you trying to accomplish with two
tables that you can't accomplish with one?
If this isn't helpful, then instead of an ambiguous word problem, please
post DDL, sample data and desired results. See http://www.aspfaq.com/5006
for info.
"George" <George@.discussions.microsoft.com> wrote in message
news:CB84E118-4A8C-43BD-9A22-6C58E98D5461@.microsoft.com...
> Hi all,
> I am trying to copy records from table 1 where field 1 is equal to "N" to
> table 2. I also want to change field1 to "Y" after the copy or delete the
> record, so that the record will not get copied again.
> Can this be done?
> Thank you,
> George|||Hi George,
INSERT INTO TABLE2 SELECT <FIELDS> FROM TABLE1 WHERE FIELD1='N'
GO
UPDATE TABLE1 SET FIELD1='Y'
GO
Hope this will solve the problem
thanks and regards
Chandra
"George" wrote:
> Hi all,
> I am trying to copy records from table 1 where field 1 is equal to "N" to
> table 2. I also want to change field1 to "Y" after the copy or delete the
> record, so that the record will not get copied again.
> Can this be done?
> Thank you,
> George

Adding and Updating in same query

Hi all,
I am trying to copy records from table 1 where field 1 is equal to "N" to
table 2. I also want to change field1 to "Y" after the copy or delete the
record, so that the record will not get copied again.
Can this be done?
Thank you,
GeorgeOne thing I need to mention: I am trying to accomplish this in the
Transformation
Thanks again.
George|||> One thing I need to mention: I am trying to accomplish this in the
> Transformation
What is "the Transformation"?|||Of course you can handle this in multiple ways, e.g. one way would be to use
Y on insert
INSERT INTO table2(field1, pk) SELECT 'Y', pk
FROM table1 t1
LEFT OUTER JOIN table2 t2
ON t1.pk = t2.pk
WHERE t2.pk IS NULL
Or not have a "field1" at all. Assuming you can identify any row in either
table uniquely, and properly identify a duplicate, you can easily use a
similar LEFT JOIN without needing a flag.
Or not have two tables at all. What are you trying to accomplish with two
tables that you can't accomplish with one?
If this isn't helpful, then instead of an ambiguous word problem, please
post DDL, sample data and desired results. See http://www.aspfaq.com/5006
for info.
"George" <George@.discussions.microsoft.com> wrote in message
news:CB84E118-4A8C-43BD-9A22-6C58E98D5461@.microsoft.com...
> Hi all,
> I am trying to copy records from table 1 where field 1 is equal to "N" to
> table 2. I also want to change field1 to "Y" after the copy or delete the
> record, so that the record will not get copied again.
> Can this be done?
> Thank you,
> George|||Hi George,
INSERT INTO TABLE2 SELECT <FIELDS> FROM TABLE1 WHERE FIELD1='N'
GO
UPDATE TABLE1 SET FIELD1='Y'
GO
Hope this will solve the problem
thanks and regards
Chandra
"George" wrote:

> Hi all,
> I am trying to copy records from table 1 where field 1 is equal to "N" to
> table 2. I also want to change field1 to "Y" after the copy or delete the
> record, so that the record will not get copied again.
> Can this be done?
> Thank you,
> George