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


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

Problems with select case executing twice, Help?

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :Windows Application
 

Dear all, I have a problem with Select case. I want to invoke different sub procedures each time a button is clicked. I decided to use select  case (not sure this the right way to achieve this goal). Here is the code:


Protected Sub AddButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddButton.Click
Dim count as integer=1
Select Case count Case 1 AddFile1() Case 2 AddFile2() Case Else ShowMessage() End Select End sub

In each sub procedure except case else, I kept increaseing count by setting it to value 2. My problem is that after executing case 1, for some reasons, it keeps repeating itself to case 2. How can I stop it after case 1 is executed? Thank you very much.

 




View Complete Post


More Related Resource Links

Problems creating a BDC file that use a unique select statment

  

I'm trying to build an BDC file that will pull information back from two tables in an Oracle database, I can import it without any errors, but then it tells me I do not have a filter when I try and select an item.  When I add a filter I get an error when I import the file.  The error I get is the following.
"Application definition import failed. The following error occurred: The IdentifierName Attribute of the TypeDescriptor named 'TestDate' of the Parameter named ':TestDate' of the Method named 'Get_TestTwelve_List' of the Entity named 'TestTwelve' does not match any of the defined Identifiers for the Entity. Error was encountered at or just before Line: '133' and Position: '16'."

Here is the section of

      <Property Name="RdbCommandText" Type="System.String"><![CDATA[

Case statement is never executing

  

Can some please advise as to why the case statement is never running

 

Imports Microsoft.VisualBasic
Imports AjaxControlToolkit


Public Class MultilevelAccordion
    Inherits System.Web.UI.UserControl
    Implements System.Web.UI.ITemplate

    Dim templateType As AccordionItemType

    Sub New(ByVal type As AccordionItemType)
        templateType = type
        MsgBox(templateType.ToString)

    End Sub

    Sub New()

    End Sub

    Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) _
          Implements System.Web.UI.ITemplate.InstantiateIn

        Dim ph As New PlaceHolder()

        Select Case (templateType)
            Case AccordionItemType.Header
                Dim myLabel As Label = New Label()
                myLabel.ID = "HeaderLabel"
                MsgBox("header")


                ph.Controls.Add(myLabel)
                AddHandler ph.DataBinding, New EventHandler(AddressOf Item_DataBinding)
            Case AccordionItemType.Content
                AddHandler ph.DataBinding, New EventHandler(AddressOf Item_DataBinding)
        End Select
        container.Controls.Add(ph)
    End Sub

    Shared Sub Item_DataBinding(ByVal sender As Object, ByVal e As AccordionItemEventArgs)

        Dim ph As PlaceHolder = CType(sender, PlaceHolder)
        Dim headerValue As String = _

Can we use Select clause in Case statement

  
SELECT CASE OT.ItemTypeID WHEN 6 THEN SELECT SUM(ISNULL("Item Cost",0)) FROM SUBTABLE IT WHERE IT.OrderID = OT.OrderID AND IT.ItemTypeID IN(6,11,12) WHEN 7 THEN SELECT SUM(ISNULL("Item Cost",0)) FROM SUBTABLE IT WHERE IT.OrderID = OT.OrderID AND IT.ItemTypeID IN(7,14,15) WHEN 8 THEN SELECT SUM(ISNULL("Item Cost",0)) FROM SUBTABLE IT WHERE IT.OrderID = OT.OrderID AND IT.ItemTypeID = 8 WHEN 9 THEN SELECT SUM(ISNULL("Item Cost",0)) FROM SUBTABLE IT WHERE IT.OrderID = OT.OrderID AND IT.ItemTypeID = 9 WHEN 10 THEN SELECT SUM(ISNULL("Item Cost",0)) FROM SUBTABLE IT WHERE IT.OrderID = OT.OrderID AND IT.ItemTypeID = 10 WHEN 11 THEN SELECT SUM(ISNULL("Item Cost",0)) FROM SUBTABLE IT WHERE IT.OrderID = OT.OrderID AND IT.ItemTypeID IN(6,11,12) WHEN 12 THEN SELECT SUM(ISNULL("Item Cost",0)) FROM SUBTABLE IT WHERE IT.OrderID = OT.OrderID AND IT.ItemTypeID IN(6,11,12) WHEN 14 THEN SELECT SUM(ISNULL("Item Cost",0)) FROM SUBTABLE IT WHERE IT.OrderID = OT.OrderID AND IT.ItemTypeID IN(7,14,15) WHEN 15 THEN SELECT SUM(ISNULL("Item Cost",0)) FROM SUBTABLE IT WHERE IT.OrderID = OT.OrderID AND IT.ItemTypeID IN(7,14,15) WHEN 18 THEN SELECT SUM(ISNULL("Item Cost",0)) FROM SUBTABLE IT WHERE IT.OrderID = OT.OrderID AND IT.ItemTypeID = 18 WHEN 19 THEN SELECT SUM(ISNULL(&qu

Select Case - Represented by Images

  
I have a question about a Select Case, and how to go about writting it. In my pages, I call to a SQL Database, that returns values from a column.  The columns present two types of data, numeric and varchar e.g 2N or .10 (they present nickles) I would like my onscreen to display images, instead of that value (once they have been found). Where 2N = imageNickle + imageNickle, as well as .10 = imageNickle + imageNickle (or display 2 of the images in place, rather) I would like to just focus on the (varchar) at this point.  Is their an easier way to write a select statement than say: Select Case howManyImages If columnValue = 2N then displayValue = "/imageNickle.jpg" & "/imageNickle.jpg" ElseIf columnValue = 3N Then displayValue = "/imageNickle.jpg" & "/imageNickle.jpg & "/imageNickle.jpg" or is this pretty simple as it is?      

add more than one case in select statement ?

  

hi all

i have this select statement

select

case when X  = 1 THEN ''

ELSE

CASE WHEN y = 1 THEN 'Y' END

CASE WHEN f = e THEN 'ok' END

END

FROM table

but

Incorrect syntax near the keyword 'CASE' the secound one

how can i solve this ?


SELECT and UPDATE query problems

  

Hello!

I have a web form that should display advertisements depending of the number of impressions (number stored in a database) and I also need to update the number of impressions when page is loaded. The advertisements are displayed on a web page, but the problem is I don't know where to insert the SqlCommand for updating number of impressions.

Labels are used for displaying the number of impressions.  


        String connectionString = WebConfigurationManager.ConnectionStrings["CMS"].ToString();
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            connection.Open();

            using (SqlCommand commandReklama = new SqlCommand("SELECT * FROM Reklama", connection))
            {
                SqlDataReader readerReklama = commandReklama.ExecuteReader();
                while (readerReklama.Read())
                {
                    string redirectUrl = readerReklama.GetString(1);
                    string url = readerReklama.GetString(2);
                    int brojPrikazivanja = readerReklama.GetInt32(3);
                    bool show = readerReklama.GetBoolean(4);                  
                    string naziv = readerReklama.GetString(5);
                    int location = readerReklama.GetInt32(6);

                    if (

Possible to use CASE in select to select different columns/values?

  

Hey everyone,

I'm trying to work some SQL to work like the following (which doesn't work/isn't allowed). Is there a way in SQL to do this?

declare @mode int
set @mode = 1

Declare @Profiles varchar(400) 
set @Profiles=''

Declare @Count int

-- This is where it's tricky.
-- If mode is 1, then we want to return the count of the records.
-- If not, we want to return the values. 
-- What we don't want to do is have to write the entire select
-- statement twice. :-)
select case @mode
	when 1 then @Count=count(1) 
	else *
from CLACX x inner join

Use of CASE statement in Select using SqlDataSource

  

Hi All,

I need help regarding the use of CASE in Select of SQLDataSource. Actually I am using FORMVIEW and in the Grid i have "Consumer Numbers" as link and on click I save the Consumer Number in Session Variable. When user go into Edit and change the Consumer Number after updation the formview was coming blank cause i was using that number for select statement now. Just need to correct the SELECT and use the case properly and want to do is

"IF CONSUMER_NUMBER = <SESSION_VARIABLE_OF_CONSUMER_NO> THEN USE <SESSION VARIABLE>

ELSE

USE FIELD "CONSUMER NUMBER

How to do that please correct.


       <asp:SqlDataSource ID="SqlDSBillers" runat="server" 
ConnectionString="<%$ ConnectionStrings:SQLE2K8 %>"

SelectCommand="SELECT Bill_Master.Bill_Master_ID,
Bill_Master.Biller_ID,
CONVERT (varchar(20),
Bill_Master.Enroll_Date, 105) AS Enroll_Date,
Billers.Biller_Code,
Bill_Master.Consumer_No,
Bill_Master.NameOnConnection,

Huge MSMerge_Contents and problems executing sp_mergemetadataretentioncleanup

  

Hello,

We are using Merge replication of SQL Server 2005 SP4 on Windows Server 2003, and I've set retention period to 14 days. I do not check the size of MSMerge_Contents, until recently the merge performance was slower than before. After checking the row number of MSMerge_Contents, I then realized the number is more than 5 million! Is this the root cause of performance downgrade? How to check if the regular cleanup has been carried out always?

I then executed only "exec sp_mergemetadataretentioncleanup" on the replication database on Publisher. After running more than half an hour, I saw there were a lot of downloads and uploads on replication monitor, abount tens of thousands! Usually the number of each run (I've set to merge data per 5 mins) is only hundreds or about a thousand.

Then, I decided to stop executing the manual cleanup and checked the row number of MSMerge_Contents, and it dropped to about 3 million. However, the replication downloads and uploads still grew, and reached hundreds of thousands!

After it all finished making so much downloads/uploads, the row number of MSmerge_Contents was still 5 million, a little less than before. 

This is beyond my knowledge, and any help will be greatly appreciated.

 


Visual Case Tool - UML Tutorial

  
The Class Diagram

The class diagram is core to object-oriented design. It describes the types of objects in the system and the static relationships between them.

AJAX GridView Checkbox Select All in ASP.Net

  
In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

Top .NET Performance Problems and how to avoid them

  
Every time I work with one of our .NET customers to help them with managing their application performance I come across the same problems as seen with other clients before: lots of ADO.NET queries, many hidden exceptions in core or 3rd party .NET libraries, slow 3rd party components, inefficient custom code

Use Case Diagram

  
The use case diagram shows the functionality of the system from an outside-in viewpoint.

Actors (stick men) are anything outside the system that interacts with the system.

Select value in gridview

  

Hi, I am new to gridview. I want to make a gridview. Its row when selected should direct me to a specific .aspx page.Each row should direct to a different page. Should I use querystrings for this? Please suggest. Regards, ap.


Visual Studio 2008 Memory problems

  

My memory in task manager reaches about 900,000K  and I don't know why it does this. Definately slows everything down, especially when I rebuild my tableAdapters, takes about 30 seconds sometimes to rebuild the project.


Problems with Forms Authentication in DD 4 site

  

Hello,  I am seeing a strange problem with Forms Authentication in my DD site.   A user logs into and can view/edit/delete data all day, but when they execute a Custom Filter against data (for example , a control DynamicData/Filters/CustomerLastNameSearch.ascx ) then the site auth fails, and redirects to the log in screen.

in web.config I have

     <authentication mode="Forms">
            <forms name=".Star" loginUrl="~/Login.aspx" protection="All" defaultUrl="~/Default.aspx" path="/" timeout="43200" cookieless="UseCookies" />     
        </authentication>

Offhand, I am thinking two things : that DynamicData/Filters path requires some special handling for some reason, or the control extension ascx is causing auth to get confused.   Has anyone else experienced this or have any suggestions?  Thanks!


Problems posting to a package

  

Hey Y'all


I'm currently creating a program that accesses a mysql package to add data to a few tables.  I'm currently getting an error that says  "

ORA-01403: no data found
ORA-06512: at "JESSE.PKG_WORKPLAN", line 42
ORA-06512: at "JESSE.PKG_WORKPLAN", line 177
ORA-06512: at line 1

"

These lines are

42: INSERT INTO WP_PROJECTS_USERS (PROJECT_USERS_ID, FIELD_UNIT_ID, PROJECT_ID, USER_ID, START_DATE, DESCRIPTION)

and 177:add_team_members(V_PROJECT_ID, V_START_DATE, v_FISC_YEAR, V_MEMBERS ,V_NUM_MEMBERS,'add');


Checking these variables in my asp.net page they are all receiving parameters.


Is there a  way to see what the database is actually receiving from the asp.net page?

Or is there another thing to be looking at?


Thanks!


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