Protected Sub GridView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PreRender
For Each gvRow In GridView1.Rows
If gvRow.RowType = DataControlRowType.DataRow Then
Dim h1 As HyperLink = CType(gvRow.Cells(0).Controls(0), HyperLink)
h1.NavigateUrl = h1.NavigateUrl & "&H=" & Request.QueryString("H")
End If
Next
End Sub
This blog is created to add all the information and experiences that I have learnt while working on MS sql server as a DBA. The blog is also updated frequently with the real world problem that I encounter hands on at work and the resolutions to resolve them. I hope this blog will be of some use to you and you will revisit. Thank you for stopping by and you are welcome to leave comments.
Wednesday, July 18, 2012
Monday, July 16, 2012
Accessing masterpage objects from child page
I had a project where I had to pass in the hospital code to the link button that was at the top of the each page . The top section of the each page was a masterpage.
I added a property called SetHospitalCode on the masterpage as follows
Public m_HosCode As String
Public Property SetHospitalCode() As String
Get
Return m_HosCode
End Get
Set(ByVal value As String)
m_HosCode = value
End Set
End Property
--------
Protected Sub DashBoard_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DashBoard.Click
If m_HosCode Is Nothing Then
Response.Redirect("DashBoard.aspx")
Else
Response.Redirect("DashBoard.aspx?H=" + m_HosCode.ToString())
End If
End Sub
I set the property from the each child page as follows
Dim getMaster As MasterPage
getMaster.SetHospitalCode = hospitalcode
where hospitalcode is the new value of the hospital from each page.
DashBoard is the ID of the linkbutton
I added a property called SetHospitalCode on the masterpage as follows
Public m_HosCode As String
Public Property SetHospitalCode() As String
Get
Return m_HosCode
End Get
Set(ByVal value As String)
m_HosCode = value
End Set
End Property
--------
Protected Sub DashBoard_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DashBoard.Click
If m_HosCode Is Nothing Then
Response.Redirect("DashBoard.aspx")
Else
Response.Redirect("DashBoard.aspx?H=" + m_HosCode.ToString())
End If
End Sub
I set the property from the each child page as follows
Dim getMaster As MasterPage
getMaster.SetHospitalCode = hospitalcode
where hospitalcode is the new value of the hospital from each page.
DashBoard is the ID of the linkbutton
Friday, June 29, 2012
Wednesday, June 27, 2012
Error:The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
Here is the sp that caused the error
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PROC_ARCHIVE_EOM]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[PROC_ARCHIVE_EOM]
GO
/** ***** Version *****
* $Revision: $
* $Date: $
* $Author: $
* $Archive: $
*
* Sample use: exec PROC_ARCHIVE_EOM
* Comments : sp to perform the monthly archive of the transactions table.
* */
CREATE PROC PROC_ARCHIVE_EOM
AS
DECLARE @myCheckdate varchar(10)
SELECT @myCheckdate = convert(varchar(10),SuccessDate,101) from dbo.JobsRunlog where JobID = 10
--SELECT @myCheckdate
If @myCheckdate = convert(varchar(10),GETDATE(),101)
BEGIN
BEGIN TRAN TRAN1
---insert into the archive table
INSERT INTO Table_Archive
SELECT p.* FROM Patient_Table p WITH (nolock)
INNER JOIN clients c
ON p.hospital = c.hospitalcode
WHERE c.active = 1
AND
year(RCVD) = year(getdate()) and month(RCVD)< month(getdate()))
IF @@error <> 0 GOTO Error_Handler
COMMIT TRAN TRAN1
END
Error_Handler:
RAISERROR('error occurred while archiving the patient table',16,1)
ROLLBACK TRAN TRAN1
Added @@tranCount check to avoid this error
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PROC_ARCHIVE_EOM]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[PROC_ARCHIVE_EOM]
GO
CREATE PROC PROC_ARCHIVE_EOM
AS
DECLARE @myCheckdate varchar(10)
SELECT @myCheckdate = convert(varchar(10),SuccessDate,101) from data2link.statusUpdates.dbo.JobsRunlog where JobID = 10
--SELECT @myCheckdate
If @myCheckdate = convert(varchar(10),GETDATE(),101)
BEGIN
BEGIN TRAN TRAN1
---insert into the archive table
INSERT INTO Table_Archive
SELECT p.* FROM Patient_Table p WITH (nolock)
INNER JOIN clients c
ON p.hospital = c.hospitalcode
WHERE c.active = 1
AND
year(RCVD) = year(getdate()) and month(RCVD)< month(getdate()))
IF @@error <> 0 GOTO Error_Handler
IF @@TRANCOUNT > 0
COMMIT TRAN TRAN1
END
Error_Handler:
RAISERROR('error occurred while archiving the patient table',16,1)
IF @@TRANCOUNT > 0
ROLLBACK TRAN TRAN1
Thursday, June 7, 2012
To find which processID the current SQLServer is running on
- Fire up the SQL Server configuration Manager
- Double Click on the SQL Server Services
- On the right hand side panel find the SQL SERVER
- Right Click on it , go to properties and the Process ID is listed on the Services tab.
Thursday, May 3, 2012
error:process could not execute 'sp_replcmds' error on Publisher with Remote Distributor
Today the replication failed on our Publisher. We have a transactional replication running from Publisher to the Subscriber and they are in two differnt machines, both using SQL 2008 R2. The exact error we got was
--STEP 1
exec sp_changedbowner [domain\user]
This made the [domain\user] account the owner and mapped it to dbo
--STEP 2
In SSMS find the replication and expand it
Expand the local publication folder
Select the publication and right click on it and seclet "View Log Reader Agent Status"
Stop the Agent and Restart the agent
Now all ther replications were back in sync.
I ran the follwoing query to see if they are back up running
select * from distribution..MSrepl_transactions order by entry_time
- Replication failed: process could not execute 'sp_replcmds' error on Publisher with Remote Distributor
- The database owner SID recorded in the master database differs from the database owner SID recorded in database 'databasename'
--STEP 1
exec sp_changedbowner [domain\user]
This made the [domain\user] account the owner and mapped it to dbo
--STEP 2
In SSMS find the replication and expand it
Expand the local publication folder
Select the publication and right click on it and seclet "View Log Reader Agent Status"
Stop the Agent and Restart the agent
Now all ther replications were back in sync.
I ran the follwoing query to see if they are back up running
select * from distribution..MSrepl_transactions order by entry_time
Thursday, April 26, 2012
Cleaning up of msdb database
Cleaning up msdb database is one of the neglected yet most important task of a sql administrator. We have some SSIS packages, full back up once a day and transactional backup in every 15 minutes. We use databaseMail extensively therefore cleaning up msdb database is a good practice.
The msdb database was 241 MB and after cleaning up ( running the following scripts) I am able to bring it down to 153 MB. I am keeping a log of the database growth in a table in every 4 hours. I do not think that the size of the msdb has to be this big. So I am leaving it the way it is and then looking at table where the file growth is captured befor I make the decision if I need to rsize the db to a smaller size.
The scripts that I ran
--removing anything before a month
DECLARE
SET @date = DATEADD(day, -30, CURRENT_TIMESTAMP)
--delete backup history
--delete old mail items
--especially, if you are sending attachements
EXEC msdb.dbo.sysmail_delete_mailitems_sp @sent_before = @date
--delete the log of the sent items
EXEC msdb.dbo.sysmail_delete_log_sp @logged_before = @date
--delete the SQL Server agent job history log
EXEC msdb.dbo.sp_purge_jobhistory @oldest_date = @date
EXEC msdb.dbo.sp_delete_backuphistory @date @date datetime
The msdb database was 241 MB and after cleaning up ( running the following scripts) I am able to bring it down to 153 MB. I am keeping a log of the database growth in a table in every 4 hours. I do not think that the size of the msdb has to be this big. So I am leaving it the way it is and then looking at table where the file growth is captured befor I make the decision if I need to rsize the db to a smaller size.
The scripts that I ran
--removing anything before a month
DECLARE
SET @date = DATEADD(day, -30, CURRENT_TIMESTAMP)
--delete backup history
--delete old mail items
--especially, if you are sending attachements
EXEC msdb.dbo.sysmail_delete_mailitems_sp @sent_before = @date
--delete the log of the sent items
EXEC msdb.dbo.sysmail_delete_log_sp @logged_before = @date
--delete the SQL Server agent job history log
EXEC msdb.dbo.sp_purge_jobhistory @oldest_date = @date
EXEC msdb.dbo.sp_delete_backuphistory @date @date datetime
Subscribe to:
Posts (Atom)