473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Why is Sub routine not firing?

347 100+
I have the following code:
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Exceptionquery()
  2.         Dim connection As System.Data.SqlClient.SqlConnection
  3.         Dim connectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx"
  4.         Dim _sql As String = "SELECT [Exceptions].Employeenumber,[Exceptions].exceptiondate, [Exceptions].starttime, [exceptions].endtime, [Exceptions].code, datediff(minute, starttime, endtime)  as duration INTO scratchpad3 " + _
  5.         "FROM [Exceptions]" + _
  6.         "where [Exceptions].exceptiondate between @payperiodstartdate and payperiodenddate" + _
  7. "GROUP BY [Exceptions].Employeenumber, [Exceptions].Exceptiondate, [Exceptions].starttime, [exceptions].endtime," + _
  8. "[Exceptions].code, [Exceptions].exceptiondate"
  9.         connection = New SqlConnection(connectionString)
  10.         connection.Open()
  11.         Dim _CMD As SqlCommand = New SqlCommand(_sql, connection)
  12.         _CMD.Parameters.AddWithValue("@payperiodstartdate", payperiodstartdate)
  13.         _CMD.Parameters.AddWithValue("@payperiodenddate", payperiodenddate)
  14.         connection.Close()
  15.     End Sub
  16.     Public Sub exceptionsButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exceptionsButton.Click
  17.         Exceptionquery()
  18.         Dim connection As System.Data.SqlClient.SqlConnection
  19.         Dim adapter As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter
  20.         Dim connectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx"
  21.         Dim ds As New DataSet
  22.         Dim _sql As String = "SELECT * from scratchpad3"
  23.         connection = New SqlConnection(connectionString)
  24.         connection.Open()
  25.         Dim _CMD As SqlCommand = New SqlCommand(_sql, connection)
  26.         _CMD.Parameters.AddWithValue("@payperiodstartdate", payperiodstartdate)
  27.         _CMD.Parameters.AddWithValue("@payperiodenddate", payperiodenddate)
  28.         adapter.SelectCommand = _CMD
  29.         Try
  30.             adapter.Fill(ds)
  31.             If ds Is Nothing OrElse ds.Tables.Count = 0 OrElse ds.Tables(0).Rows.Count = 0 Then
  32.                 'it's empty
  33.                 MessageBox.Show("There was no data for this time period. Press Ok to continue", "No Data")
  34.                 connection.Close()
  35.                 Exceptions.saveButton.Enabled = False
  36.                 Exceptions.Show()
  37.             Else
  38.                 connection.Close()
  39.                 Exceptions.Show()
  40.             End If
  41.  
  42.         Catch ex As Exception
  43.             MessageBox.Show(ex.ToString)
  44.             connection.Close()
  45.         End Try
  46.     End Sub
  47.  
and when I click the button:

Expand|Select|Wrap|Line Numbers
  1.     Public Sub exceptionsButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exceptionsButton.Click
  2.  
I get the error Invalid Object name 'Scratchpad3' on this line:

Expand|Select|Wrap|Line Numbers
  1.     adapter.Fill(ds)
  2.  
I have tried to debug this and can see that the query is correct, that the values that are being passed to the sql server are correct but it doesnt look like my code is firing off the Exceptionquery Sub. Can anyone help me figure out why this sub isn't working? I thought to call a sub all you had to enter was the name of the sub such as this line:

Expand|Select|Wrap|Line Numbers
  1.    Exceptionquery()
  2.  
I have also verified that the mapping of the buttonclick event is mapped correctly. I have other subs that I am calling in almost the same way and those work. Any help would be appreciated.

Thank you

Doug
Feb 4 '11 #1
1 1354
If both subs are in the same class then that code should be fine. You can try putting:

debug.writeline("Exceptionquery Run")

at the start of the Exceptionquery sub and then you will see for sure if it is firing or not.
Feb 25 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: John Kiernan | last post by:
I have a routine in the MouseUp of a 'Save' button on a form. The button is a Submit button. If I find anything wrong in my routine, I alert the user and return a False. If I find nothing, I...
3
by: Mike | last post by:
Hi, I am adding controls dynamically in a WebForm, but none of these controls' events fire. Here is the class code I am using. I have tried so many things, but nothing works :-( namespace...
13
by: Chris | last post by:
I can create Javascript confirm message boxes during page creation, etc adding them to the button attributes (many good posts on this!). But how can I add this event after the button is pressed? I...
6
by: crk2 | last post by:
Here a simple one. (At least I think it is?) and any help would be truly appreciated. I have an inherited textbox on my form based on a custom texbox control. It looks something like this ...
4
by: tshad | last post by:
I just started working with VS.net 2003 and am trying to get a Web Service running. I got it working fine in VB.Net, but I can't seem to get it to go to the Form_Load handler to call the service. ...
1
by: JStemper | last post by:
I have a client side jscript validation routine that I am calling on submit. This routine makes and AJAX call back to a method on the server which checks for duplicate records in a DB. (this works...
19
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
13
by: JP.Gantlin | last post by:
i gotta routing to fire off once a day, I figure the first hit of each day will cause it to run. would i keep track of that in the global.asax and a session variable?
4
by: jake | last post by:
I am new to multi-threading. Here is my scenario: foreach (<file in a certain folder>) new Thread((ThreadStart)(delegate { processFile(<file>); })).Start(); sometimes misses firing some...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.