SQL Query - If/Then/Else Logic?

Oct 15, 2010

I have 3 tables:Sales data - SaleID, Date, StoreID, CategoryID, Cost, Retail

Store names - StoreID, Name
Category names - CategoryID, Name

I have a dgv bound to my sales table, and 2 comboboxes, one each bound to the remaining tables, with display member set to the name, and value member to the ID.

An ID of -1 represents "All Stores" or "All Categories"
An ID > -1 represents a specific location or category

So, can I use some sort of If,Then,Else logic to do something like this:

SELECT (*) FROM Sales
WHERE (IF @StoreID > -1 THEN StoreID = @StoreID ELSE True)
AND (IF @CategoryID > -1 THEN CategoryID = @CategoryID ELSE True)
AND Date BETWEEN @Date1 AND @Date2

I've found some different examples of If/Then/Else and Select Case type logic for SQL using google, but they don't seem to fit my situation, and I'm not sure how to apply that to what I'm attempting here.

View 2 Replies


ADVERTISEMENT

Gradually Transition To NHibernate Persistence Logic From Existing ADO.NET Persistence Logic?

Sep 3, 2010

The application uses ADO.NET to invoke sprocs for nearly every database operation. Some of these sprocs also contain a fair amount of domain logic. The data access logic for each domain entity resides in the domain class itself. ie, there is no decoupling between domain logic and data access logic. I'm looking to accomplish the following:

[Code]...

View 2 Replies

Sql - When Run The Query In Query Analyzer, It Returns One Row But When Use The Same Query, No Rows Are Returned?

Aug 19, 2010

Here is the code:

Function getData(ByVal id As String)
Dim reader As SqlClient.SqlDataReader
Dim statement As String

[code].....

View 1 Replies

.net 4.0 :: Get/set Properties Without Logic?

Jan 19, 2012

In many of the articles I have read on the web say that when creating properties in vb.netthey should use the get/set methods and a private/protected member variable in the class.

Like so:
Public Class Person
Private _name as string

[code].....

View 3 Replies

How To Do First, Previous, Next, Last Logic

May 1, 2009

in my page Having 4 Buttons ..(FIRST,PREVIOUS,NEXT,LAST) ..i am confusing to this one..

Actually what i am doing is Iam developing one efrom Designer in this user is adding pages..

so We have given These Buttons (before told)..so user click on First Button page goto Starting page and When click on Next Button Goto Next page ..like this

View 5 Replies

When Creating A Query Error "The Schema Returned By The New Query Differs From The Base Query"

Feb 29, 2012

When Creating a query using the sear Criteria Builder . I keep getting the error : "The schema returned by the new query differs from the base query" what does that mean and how do i avoid this problem in future

View 2 Replies

Getting Refresh Logic Error

Mar 4, 2012

I've got a problem when I'm trying to refresh my form. I've narrowed it down to why I'm getting this error so I'd be interested to hear people's opinions because logically, I don't think I'm approaching this the correct way.

I read from a table that gets x number of records. From the results, I create dynamic check boxes. It's OK if x is greater than the previous refresh but when it's less than, I can still see the old objects.

If I completely close the form and re-open it, it works fine and that is exactly what I'm trying to emulate. However, I'm failing miserably. Here's a broken down version[code]...

View 5 Replies

IDE :: Logic To Allow Special Characters?

Oct 14, 2009

I have a datafield [Money] of datatype float.when i input currency value with $,or , it throws an error.How do I allow $ or "," to this field without changing the datatype(I know changing to type money may fix it)

View 3 Replies

Linq To Xml: Use Logic While Creating Xml?

Feb 28, 2011

While building an xml document I require to use logic to dictate the outcome of the xml; logically it is similar to the following piece of code (although this does not work):

Dim buildElement As Boolean = True
Dim xe As XElement = _
<xml>

[code]....

I have managed to do this using the method show below, is this the suggested way of doing this or is there a better one??

Dim buildElement As Boolean = True
Dim xe As XElement = _
<xml>

[code]....

View 1 Replies

Logic Check Database ?

May 2, 2010

How can i write logic to check is it my sql statement being insert into my database ? is there any ways to create or thing can check thru by using webservice?

View 13 Replies

Logic To Calculate Age And Age Unit

Apr 10, 2012

I want to create a logic to calculate the age and unit from entered birth date. eg: If the difference between birth date and current date is >= 24 months, I will want it to display the age in years. If >= 8 weeks, I will want it to display it in months and so on here's my code

[Code].....

View 9 Replies

Programming Logic Upgrading From VB 6 To .net

May 26, 2010

I have been programming in vb6 for few time ago and i used open SQL Server connection and command objects to make database transactions. I have been searching for similar approaches in vb.net too but not finding any starting point. How can we work similarly in vb.net application?

View 2 Replies

Put Behaviour Logic When Using POCOs?

Jan 26, 2011

I never used POCOs, so I have the habit of putting a lot of logic in my business object classes. Hence I believe I'm missing some important concepts about class-layouts, and the thought-process that is needed here.

Say if you have two classes; Company and Employee. Could you give some examples of what classes you would build "around" these that take care of various behavior/validation etc.? (Like some class names, and a brief description of their purpose)

View 2 Replies

Run Logic If Field Is Tabbed Off Of

Apr 30, 2012

Looking at the following

Instead of a message box, how can I make it round when the unit price field is tabbed off of. If they tab in to the unit price field don't round, if they tab out of it, do.

Private Sub UnitPrice_LoseFocus(AllowLoseFocus As Boolean)
' Runs logic to round unit prices with long decimals
' Enter price rounding here

[Code]....

View 2 Replies

Using Images With Conditional Logic?

Apr 5, 2009

I want to be able to call forth hundreds of different photos be selecting them from a listbox or something of that nature.

Normally, if I only had a few images, I would amke their visibility false and then use If statements to turn on their visibility once it is selected. However, putting hundreds of images on to a form and then changing their visibility, seems like a pain.

I was wondering if there is a way to call forth each photo within the resources folder when an item is clicked so I don't have to put each one directly on the form.

View 5 Replies

VS 2005 How To Implement Some IF/Then Logic

Mar 17, 2009

I'm sure this should be easy but I'm having trouble getting my head around it. I shall try to explain what I need as best I can.I have a string called SoftwareGroupName. If that string is empty, I need to run some code that logs a call in our Helpdesk. So far, so simple.I then check two other variables, AuthorityLevel and InstallType. If the AuthorityLevel is anything other than "OnRequest" then a call is logged in the Helpdesk System. Again, so far, so simple.

The problem occurs when the AuthorityLevel is "OnRequest". At this point, the application should again log a call in the Helpdesk Call with a status of "Resolved" as well as add the user to the relevant group in Active Directory.What I need to be able to do is, effectively, say "If the AuthorityLevel is OnRequest and SoftwareGroupName is not empty then go ahead and create the call and update the group. However, if softwaregroupname is empty then DON'T even try and update the group and create a call with a different status (e.g. Assigned).Here's what I'm doing so far. But it seems wrong to have to check that SoftwareGroupName is empty twice.

[Code]...

View 4 Replies

VS 2008 Logic With Days

Oct 7, 2009

We have a system were a user chooses a combination of days from a calander. We then insert a values in the databse based on the following [code]So if they picked Monday and Friday we would insert 34, or if they picked Monday,Tuesday and Thursday we would insert 22.Now my question is how do I reverse this easily in code, to find out what days they have picked. So I get fed 22 from the database how do I figure out what combination of days make up that value. The only thing I can think of is creating the mother of all case statements but I know there must be a better way.

View 4 Replies

.net - Optimization With Visual Studio Or A Logic Bug?

Feb 3, 2011

I have an small physics toy application I am developing. It works fine except the particles will not push each other away, only pull towards, I debugged that sub going through it command by command and realised the value 'H' would not change, what ever it was set to during the first pass through the sub is what it kept, the only way to change this value is to manually set it i.e 'h = 1'. Once the calculation is redone on the 'H' value it resets to what it was previously, even though the x1,y1,x2,y2 are all different, thus meaning H should be different.

I think it is me that has made a mathematical mistake somewhere, but I cannot see where it is. I need a fresh pair of eyes to look over my work. Please let me know if you find anything.

[Code]...

View 1 Replies

Accessing Logic Value On Parent Form?

May 12, 2010

I have a button on my form that loads a dialog. I have a logic on here that I want to test, what ever method I try I alway's get 'Object reference not set to an instance of an object'dialog1.vb:

Code:Public mainform As SettingsMainForm If mainform.LogicCheck.Checked Then textbox1.text = true End if

View 2 Replies

Add Login Logic To Current Website?

Nov 23, 2011

I am a student working in a co-op position. My project is to add a login page to an existing site (made using FrontPage, I believe) and I am using ASP.NET in vs2010 (VB). I would like to NOT use the login control/membership tools in ASP.NET. I was hoping to make my own login and use session variables to keep track of the users and determine their role off of a field in a table located in the database that currently exists for the site.

Like I said, I am still a student and haven't had a lot of web application experience. I'm not asking for someone to do this for me. I have spent a few days looking over the asp site, the msdn site, and several others but I just can't understand it yet.

View 1 Replies

C# - (.net) Logging The Function Logic Of Program?

Jul 22, 2009

I'd like for debugging purposes to be able to log what functions are called and in what order. So I've been just putting Debug.WriteLine("myFunctionName(args)") all over my functions, logging it in the end to a file. Isn't there a better approach to do this?

View 4 Replies

Create A Panel Visable Logic?

Aug 15, 2011

I am going mad trying to sort this logict

Public Sub Panels()
If RadPanelSearchCur.Visible = True Then
RadPanelTenant.Visible = False
'RadPanelProp.Visible = False

[code].....

the idea is if one panel is opened the others are closed?

View 3 Replies

DB/Reporting :: Passing Logic On Datagrid/

Aug 10, 2008

I need to validate the users region against the region in the productlist. What I have is:
Several values stored in Session when a user logs in, one of which is Session("SLID") which is the users database primary key value and is used to perform a database lookup whenever a users info is needed. This is done via User.vb I am attaching the file

View 2 Replies

Event Logic And Phidget Interface?

May 7, 2010

I have a Phidget Interface board that has 16 digital inputs. When I trigger an input it fires an event. The problem is that the event fires twice because it fires when the input goes high AND when the input goes back low. I just need it to trigger once per input state change (Input to high and input back to low = 1 button press There are 10 types of people in the world: those who understand binary, and those who don't.

View 5 Replies

IDE :: Managing Dates Using Business Logic?

Feb 16, 2010

i am currently trying, to create some sort of a business logic within my class, that contains information about a machine, now this machine once sold, can be re-sold by its owner. the company needs to keep track of the machine and its owner for warranty claim purposes.the class takes in two values, a from date and a to date.now when a new owner is added to the owner collection of the machine, the TO date of the previous owner should automatically be updated to one day less than the From date of the new owner that is being added.

View 1 Replies

LINQ With Integer Array LOGIC

May 24, 2010

Apologies if this is the wrong forum (the other LINQ based ones didn't seem appropriate). I'm writing a very simple code crack game, a player enters FOUR numbers in a text box which are compared against the random number generated on form launch. Random number generator

[Code]...

View 15 Replies

Logic For Checking A Boolean Of An Object?

Mar 7, 2012

I have a hashset (of posdata), pos data containing a boolean and a label containing the hashkey. I need to draw up a condtion where it will check that if a boolean for two or three different records does not equal to false. And if the condition is true i want to set the boolean of the two or three records to false. Here is an attempt,

ElseIf (position.strLabel = "b2" And position.blnAvail <> False) And (position.strLabel = "b1" And position.blnAvail <> False) And (position.strLabel = "e1" And position.blnAvail <> False) Then

[Code]....

View 1 Replies

Logic To Calculate Business Hours?

Aug 16, 2010

I have tried searching all over the web for this logic. Got many but half of them did not match what i was looking for and half were malfunctioning.I want to calculate business working hours between 2 datetime, where in I should be able to set the working hours as well as weekends and holidays should not be calculated.

View 7 Replies

Logic Using Files And Parallel Lists

Mar 25, 2011

Direction with some logic using files and parallel list.. I have to create a summary of a current clients portfolio using the client id I have in a textbox. I've everything to work except the summary of the client. I have several sub functions that I can use that I've made up in my code. They are frmMain_Load that have a file and a string holding the client txtfile to a file

Dim clientFile As System.IO.StreamReader 'file of client data
Dim clientFileName As String = "faclient.txt" '

And I have two functions Private Sub GetStockData(ByVal sCode As String, ByRef sName As String,ByRef sPrice As Double) and Private Sub GetNextTran(ByRef tid As String, ByRef tcode As String, ByRef tdate As Date, ByRef ttype As String, ByRef tshares As Integer, ByRef tprice As Double). I have to add to a label,a summary tha shows the stock code, stock name, number of shares currently held, current share price and value(shares times current price). The number of shares currently help will be the result of adding the shares bought and subracting the shares sole for that stock. If the number of shares help turns out to be zero(client sold all the shares they bought), do not display the line. The program should not assume there is an upper limit to the number of different stocks a client can hold. I know is alot..But here is what I have so far..

Private Sub btnSummary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSummary.Click
'get a summary of client portfolio and value
Dim summaryCodeList As New List(Of String) 'holds scode
Dim sharesList As New List(Of Integer) 'holds tshares

[CODE]...

View 4 Replies

Populate RadioButtonList Using 3-tier Logic?

Oct 21, 2010

The below code doesn't work becuase I need to somehow feed the DataText and Value fields. I need to somehow amend the code to allow me to populate my RadioButtonList and to fit inside my 3-tier architecture. My first time doing this so I'm a little lost.

' rblAnswers.DataTextField = dt.Columns(1).ToString
' rblAnswers.DataValueField = dt.Columns(0).ToString
'Calls

[code]....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved