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

Top 5 Contributors of the Month
Post New Web Links

Check to see if items do not exist

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :Sql Server

I basically have 3 queries that I need to run to provide specific answers to my users.  Whether the machine is Running(Deployed), Not Running(Available) or "In Maintenance"(Unavailable).  The first and third queries run fine.  However the second one (in Bold)is where I'm having additional trouble, it needs to check to see if the Machine is "In Mainenance" or not.  If it is not in mainenance then it should get its value from the Designated amounts Table, Else it should give the value of '0'

Problem Query

"Not Running" but able to if needed.
Needs to check to determine if it is Available(i.e. Not Running) ("SELECT  TOP (1) CASE WHEN V300938F <= '.1'") it then needs to check to see if it matches this Criteria  "WHERE   (dbo.Designated_Amount.Unit_Code = '114') AND SIMS.Event_Type in ('IR','ME','MO','PE','PO','RU','SF','U1','U2','U3') AND (dbo.SIMS.EventEndTS IS NULL) AND (dbo.SIMS.Avail_Cap = 0)" then it should return a '0', if it doesn't match the Where clause it should return the value from the Designated_Amounts table.

declare @Amount float

select top 1 @Amount =  CAST(dbo.Designated_Amount.Amount AS Float)

View Complete Post

More Related Resource Links

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

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

How to apply color to selected number of items in check box list and drop downlist

Hi all,    I want to apply color to selected number of items in checkbox list and seleted number of items in drop downlist for e.g color red for few items and black (default). I have a bit value set in data base so if bit is set to 0 then red and if 1 then back. Please help me.  

'Dropdownlist' has a SelectedValue which is invalid because it does not exist in the list of items


I have a dropdown list that has a bind on it and I get this error. Why am I getting this error and what can I do to fix it. here is the code for the dropdown I currently have:


 <asp:DropDownList  ID="DDLPreferred" AppendDataBoundItems="true" SelectedValue='<%# Bind("PREFERRED_COMMUNICATION") %>'  runat="server" TabIndex="15">
                <asp:ListItem Text="none" Value=""></asp:ListItem>

				<asp:ListItem>Home Phone</asp:ListItem>
				<asp:ListItem>Work Phone</asp:ListItem>
				<asp:ListItem>Cell Phone</asp:ListItem>


Using custom code on report services to check if directory does exist or not (need help)


I am trying to check if a directory does exist.  I have used the vb.net to create a very small function and embedded into the "Custom code:" section of Report Properties.  It’s output is a return of Y or N (string) or 1 or 0 (Integer) if directory exist or not. 

Here is the code which returns a String

    Function ifDirExist(ByVal mypath As String) As String

        Dim flag As String

        If Not System.IO.Directory.Exists(mypath) Then

            flag = "N"

Dropdownlist error: SelectedValue which is invalid because it does not exist in the list of items.


I have a dropdownlist in a detailsview edit Item template. Also I have two tables - Employee and Main. In the Employee table I have column EmpId and AssignedTo. In the main table I have EmpId which is connected to the Employee table. 

The detailsView has a label which shows the AssignedTo name for a particular record and it works fine. But if I click the edit button to shwo the dropdownlist in the editItemTemplate it is givig me the above error.

The code is:

<asp:DetailsView ID="dtvAssign" runat="server" AutoGenerateRows

checkboxlist save check items to SQL (not concatenate)


I search through the web and I only found out how to concatenate.

I have a checkboxlist that is a list of Authors, it is included in my ADD BOOK form. Take note that a book can have many author so I need checkboxlist.

Instead of having this in my SQL table.

Table 1: Book

Book_ID      Book_Title       Book_Author

1                 My Book          Mark, Mike, John  <-- Concatenate

I need this.

Table 1: Book

Book_ID      Book_Title        Book_Author

1                 My Book            Mark

1                 My Book            Mike

1                 My Book            John

It's required that for one row there's only one author but it can have the same book id and title.

My current code

string add = "insert into Book values (@booktitle, @author);
SqlCommand cmd = new SqlCommand(add, con);
cmd.Parameters.Add("@booktitle", SqlDbType.NVarChar).Value = booktitle.Text;

How to check for exist word before inserting?


This is what I have at the moment.

insLusHmoobDataContext lusHmoobDC = new insLusHmoobDataContext();

lusHmoob lhbLusHmoob = new lusHmoob();

lhbLusHmoob.wordID = Guid.NewGuid();
lhbLusHmoob.word = txtWord.Text;
lhbLusHmoob.usage = txtUsage.Text;
lhbLusHmoob.hmgTrans = txtEnglishTrans.Text;
lhbLusHmoob.engTrans = txtEnglishTrans.Text;
lhbLusHmoob.originate = txtOriginate.Text;
lhbLusHmoob.modDate = Convert.ToDateTime(DateTime.Now.ToLongDateString());
lhbLusHmoob.insertDate = Convert.ToDateTime(DateTime.Now.ToLongDateString());

Is there a way to check if the word already exist in the database before the insert is commited? Can I somehow incoporated into this Insert or do I have to do my verification separately?

How can i check the uploaded document is already exist, in Library


  I want to restrict the user in uploading the file to library, if the uploading file is already exist. I upload all the document in the RootFolder of  Library and it contain 1000's of document. How can i check the uploaded document is already exist, programatically. 

Check if Site, Document Library or Folder exist


Hi All,

I need some code using the webservice to check if a Folder, Document Library or SubSite exist. The purpose is basically to check if it exists before trying to create it.

I've found that I can detect a Document Library (but not Site or folder) with this:

  • list.Url =


  • XmlNode


    list = list.GetList("MyDocLib");

It returns some information if found one and an error (Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-

How to check the document already exist in the Document library


  I am inserting a document in a library, while inserting a document i want to check this document is already in my document library. how can i do this using custom webpart.

Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

jQuery: Styling DropDownList Alternating Items (Rows)

In the following example, I will show how you can style any asp:dropdownlist very easily.

The example demonstrates how you can change alternating row items background color, using the fadeTo() to add a nice touch in the dropdownlist. You can change alt rows with a couple lines.

Check All with JQuery and a Asp.Net GridView

Display a Grid on the screen with a checkbox in each row. At the bottom of the page have "Check All" button.

Typically if I need to do anything interesting I use a template column. So my GridView will look like the one below (most other columns removed for readability). The only interesting point to note is the CssClass="ApprovalCheckBox" in the CheckBox ItemTemplate.

Hide a repeater in ASP.NET C# if the DataSource contains no items?

I have an ASP.NET page that uses a repeater nested within another repeater to generate a listing of data. It's to the effect of the following:
In the (C#) code-behind I'm basically using LINQ to pull a listing of information from an XML document and bind that information to the first repeater.

Searching for the answer to this, it seems the method is to determine whether the data for the nested repeater is empty. If it is, then you set the visibility of the repeater to false.

Creating SharePoint items with CreateItemActivity

Instead of creating new list items from code in your workflow you can use CreateItemActivity. CreateItemActivity can be used for creating list items or files. Properties of interest for this activity are the following (most of them are self-explanatory):

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).

HttpContext.Items and Server.Transfer/Execute

The problem was basically that when a Server.Transfer call was applied the script container (and also various ClientScriptProxy script embedding routines) would potentially fail to load up the specified scripts.
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