.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Santhakumar Munuswamy
Fauzul Azmi
Asad Ali
Post New Web Links

SQL Job does not fail if Targeted drive does not exist

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :Sql Server
 
I created a job Copy backups to M drive which copies backup files from one folder to another, this job runs ok, The only problem is the job does not fail if there are no backups to copy and also if the target locatioin folder on the M drive or the M drigve it self is not available. I would like the job to fail if there are no backup files to copy and also if the Target drive is unavailable Any ideas... Thanks   USE master declare @sql varchar(2000) set @sql = 'copy "D:\Program Files\Microsoft SQL Server\MSSQL\Backup\Sam\SAM.BAK" "M:\Program Files\Microsoft SQL Server\MSSQL\Backup\Sam\SAM_' + CAST(DATEPART(YEAR,GETDATE()) AS VARCHAR(4)) +  RIGHT('0' + CAST(DATEPART(MONTH,GETDATE()) AS VARCHAR(2)),2) +  RIGHT('0' + CAST(DATEPART(DAY,GETDATE()) AS VARCHAR(2)),2) + '.BAK"' exec master..xp_cmdshell @sql set @sql = 'copy "D:\Program Files\Microsoft SQL Server\MSSQL\Backup\master\master.bak" "M:\Program Files\Microsoft SQL Server\MSSQL\Backup\master\master_' + CAST(DATEPART(YEAR,GETDATE()) AS VARCHAR(4)) +  RIGHT('0' + CAST(DATEPART(MONTH,GETDATE()) AS VARCHAR(2)),2) +  RIGHT('0' + CAST(DATEPART(DAY,GETDATE()) AS VARCHAR(2)),2) + '.BAK"' exec master..xp_cmdshell @sql set @sql = 'copy "D:\Program Files\Microsoft SQL Server\MSSQL\Backup\msdb\msdb.ba


View Complete Post


More Related Resource Links

URL Rewrite causes AppSettings to Fail?

  

Hi there,

I just implemented basic URL rewriting to change a page from, for example, /member.aspx?id=123 to /member.aspx/erik.  That works and I'm happy with it.  However, I am now getting an error message that states "the connectionstring property has not been initialized".  Normally, I've been storing the connectionstring in web.config, and I access it with:

Dim Connect As SqlConnection = New SqlConnection
Dim ConnectString As String
ConnectString = ConfigurationManager.AppSettings("linktomysite")
Connect.ConnectionString = ConnectString
Connect.Open()

This is what I do on every other page of the site and it works fine.  The only way it will work on the page where I'm URL re-writing, however, is if I replace "ConfigurationManager.AppSettings("linktomysite")" with the actual connection string itself.  For security reasons, obviously I would prefer to keep that info out of the page.  What can I do?

Thanks,

Erik


Fix: The type or namespace name 'EntityDataSource' does not exist

  
Today's stupid mistake had me going in circles in my Web application project. The error message was: The type or namespace name 'EntityDataSource' does not exist. As the rest of the error message suggests, I must be missing an assembly reference. Nope, I'd already added in the references to Entity : System.Data.Entity System.Data.Entity.Design After much frustration until after 1 a.m., I gave up and went to bed. This morning I realized that what it wanted was the WEB Entity! System. Web .Entity System...(read more)

SPGridView Not Appearing When Rows Exist

  

I have added the contents of a DataTable to an SPGridView control.  When there are no rows in the DataTable it shows the message "There Is No Data" which is correct. 

When there are rows in the DataTable the SPGridView does not appear at all.

What could the issue be?

The code is below:

DataTable gridTable = new DataTable();
gridTable.Columns.Add("Assigned To");
gridTable.Columns.Add("Comment");
gridTable.Columns.Add("Outcome");		

queryDPM.ViewFields = "<FieldRef Name='AssignedTo'/>" +
					  "<FieldRef Name='RequestDPMReviewerComments' />" +
					  "<FieldRef Name='WorkflowOutcome' />";

sQueryStr = "<Where>" +
				 "<And>" +
					"<IsNotNull>" +
					 "<FieldRef Name='RequestDPMReviewerComments' />" +
					

Targeted Audiences not working

  

I am looking to fix my Targeted Audiences on my Intranet Site.  Prior to SP2, I was able to choose SharePoint groups within the Targeted Audiences on web parts, left navigation bar, etc.  I no longer see any of the SharePoint groups. ("There were problems searching audiences. please contact the sys admin") I can see Global and Distribution/Security groups.  After researching, I found a hotfix that states:

"After you install the updates that are described in Microsoft Knowledge Base articles 952294 and 946517, Microsoft Office SharePoint 2007 audience targeting stops functioning for nested SharePoint groups for global navigation and for any SharePoint group audience targeting for Web parts. The navigation links and Web parts in these cases are not visible at all. Therefore, they are inaccessible to the user targeted."

 

This makes perfect sense, because it is only on my Intranet site (nested groups) where I am having issues.  Other site collections are working fine.  <

CS0103: The name 'Helper' does not exist in the current context

  

Hey i have a Class named Helper.cs inside my App_Code folder.

And i get this error:

Compilation Error



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: CS0103: The name 'Helper' does not exist in the current context

Source Error:

Line 26:         {
Line 27:             SqlConnection con = new SqlConnection(Helper.ConnectionString());


The name 'User' does not exist in the current context.

  

Hey guys,

I've got a literal control to display the username of the user logged into our companies intranet system, originally I had a LoginName control but couldn't get strip to remove the domain from the username (as the format is domainname\username) so I'm trying it this way.

    protected void Page_Load(object sender, System.EventArgs e)
    {
        string[] Parts = User.Identity.Name.Split("\\");

        if (Parts.Length == 2)
        {
            loginName.Text = Parts[1];
        }
        else
        {
            loginName.Text = User.Identity.Name;
        }

    }


    protected void Page_Load(object sender, System.EventArgs e)
    {
        string[] Parts = User.Identity.Name.Split("\\");

Word save file on SharePoint via mapped drive

  

Hi, I have a Document Library mapped to a drive letter. I am able to browse the drive through Windows Explorer. However when I try to save a document to the drive Word returns, 'Unable to connect to the Web server.' .  I have been unable to find any information regarding this error message. If I try to create a document in the Document Library through Windows Explorer and the mapped drive, I get a different error message: 'Unable to create the file 'New Microsoft Office Word Document.docx' There is no user session key for the specified logon session.' After I click OKand refresh the directory, a 0 KB New Microsoft Word Document.docx file has been created. When that file is opened, it is in Read-Only mode.

Environment:

Windows Server 2003 R2
Webclient service started
Signed into the Microsoft Online Services Sign in Application
IE configured through the sign in application
site added to the trusted sites in IE

Thank you again for your input.


$.ajax post from asp.net page and __viewstate causing call to fail

  

Hello

Now I know that I won't be sending viewstate and eventvalidation in my ajax calls and that I will only want to send the actual form fields for efficiency purposes but I will need to know the answer to this question, to inform the more junior members of the team and my manager, so if anyone has any answers they are most welcome.

I have a simple form as follows

<form id="form1" runat="server"> 
<p>Field1: <

How can i check if record already exist in sql-server database ...

  
How can i check if record already exist in sql-server database ...

VS 2010 XAML Design View Load always fail with a Type Load Exception

  
Create a new WPF project in VS and change nothing. The Design View will fail to load with the error below. Error    1    Could not load type 'Microsoft.Expression.DesignModel.Core.ISharedInstanceBuilder' from assembly 'Microsoft.Expression.DesignModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Microsoft.Expression.DesignModel is an assembly from Expression Blend. I ever installed Blend 4 RC and uninstall and install Blend 4. I Reflector the assembly I have under Blend 4 bin folder. And cannot find a interface named ISharedInstanceBuilder. But the WPF project is a Template project without any changes. How it get related with Blend 4? And how to fix it? Thanks.  

Login control - Controls do not exist in current context

  
Hi all,Trying to set up the Login control as a User control, but none of the controls exist in the current context?None of my code below is recognised? What's going on here please? I've rebuilt the solution many times.if (Membership.ValidateUser(this.UserName.Text, this.Password.Text))        {            FormsAuthentication.RedirectFromLoginPage(UserName.Text, RememberMe.Checked);        }        else        {             Msg.Text = "Login failed. Please check your user name and password and try again.";        }

Why does .NET Framework require 841 MB hard drive space on C:

  
Just downloaded .NET Framework 4 from Microsoft website. Installation says it requires 841 MB space on my C: drive. Why so much? I am presuming that this is in addition to the space for the other versions of .net installed. This is not going to be installed without a very good reason for this much space required. Can anybody enlighten me on this? Any way to lighten the space requirement load?  

How to make SSIS Package Fail when something goes wrong

  
Hello, Is there any way I can make the package (SSIS 2005) fail when something happen? Like: if some value become zero I will to make the package fail from with in the SSIS, so that the AgentJOB  that started this package will know? Thanks, Prabhat Nath

SQL Server doesn't exist or access denied while connecting with Access 2010 ODBC

  
Hello all. I am using Access 2010 and SQL Server 2008 (locally). I can easily connect to server using SSMS and it works excellent. But when I want to import a table to Access 2010 using ODBC, it says that "SQL Server doesn't exist or access denied". It worked previously - almost 3 days ago, but now, it doesn't! Please help! Thanks Mohammad Javahery

Transactional Publication With Article Using DATE Datatype Causes Snapshot Agent to Fail with Error

  
So I am using SQL Server 2008 Enterprise Edition (64Bit) and have run into a strange problem that is baffling me. I have two tables that I need to replicate.  They are identical in specification except the name (one is for monthly stats and one daily stats) CREATE TABLE [dbo].[statsDailyLite]( [EntryDate] [date] NOT NULL, [SetID] [int] NOT NULL, [ProductID] [smallint] NOT NULL, [Hooks] [int] NOT NULL, [AdViews] [int] NOT NULL, [Clicks] [int] NOT NULL, [UAdViews] [int] NOT NULL, CONSTRAINT [PK_statsDailyLite] PRIMARY KEY CLUSTERED ( [EntryDate] ASC, [SetID] ASC, [ProductID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ) GO CREATE TABLE [dbo].[statsMonthlyLite]( [EntryMonth] [date] NOT NULL, [SetID] [int] NOT NULL, [ProductID] [smallint] NOT NULL, [Hooks] [int] NOT NULL, [AdViews] [int] NOT NULL, [Clicks] [int] NOT NULL, [UAdViews] [int] NOT NULL, CONSTRAINT [PK_statsMonthlyLite] PRIMARY KEY CLUSTERED ( [EntryMonth] ASC, [SetID] ASC, [ProductID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ) GO They both conatin a thousand or so test rows of data, and they are both in a transactional publication going to another SQL 2008 box. Now when the tables are empty

Distributed Transactions fail on Linked server

  
We get the below error while performing a distributed transaction on linked server. We have several linked servers configured in the source server and all of them succeed with the distributed transaction except on one.   We did all the basic troubleshooting and moreover the distributed transactions work fine if we use a remote server instead.   Need your expert guidance in resolving this issue     Error:   OLE DB provider "SQLNCLI10" for linked server "SERVERNAME.REDMOND.CORP.MICROSOFT.COM" returned message "No transaction is active.". Msg 7391, Level 16, State 2, Line 3 The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "SERVERNAME.REDMOND.CORP.MICROSOFT.COM" was unable to begin a distributed transaction.     Test code:   begin distributed transaction   select top 10 * from [SERVERNAME.REDMOND.CORP.MICROSOFT.COM].master.sys.objects   ROLLBACK     Source server :      Microsoft SQL Server 2008 (RTM) - 10.0.1779.0 (X64)        Nov 12 2008 12:10:04        Copyright (c) 1988-2008 Microsoft Corporation        Enterprise Edition (64-bit) on Windows NT 6.0 <X64> (Build 6001: Service Pack 1) (VM)     Target server :     Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)        Jul  9 2008 14:43:34        Copyright (c) 1988-2008 Microsoft Corporation        Enterprise Edition
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend