Solved

Procedure Sub Main in VB.Net

Posted on 2014-01-12
9
383 Views
Last Modified: 2014-01-19
I'm new to VB.Net / Visual Studio . . .

I'm trying to write some simple sub procedures to interact with a SQL Server database - upload some files to a filestream column and run some stored procedures etc. Using the Empty Project template, I've created a simple project consisting of a single module and the appropriate references (System, System.Data). The problems is that although I've written a few subs, I can't seem to run or debug anything except the Sub Main procedure.

Obviously missing something basic here.
0
Comment
Question by:TimHudspith
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 14

Expert Comment

by:Matti
ID: 39774623
Hi!

binding on windows form and using it in sub main won't work, if it this case you must reorganize the database connection in the load process of the application.

matti
0
 

Author Comment

by:TimHudspith
ID: 39774724
The code is in a module, not a form. The code I have inside Sub Main runs (connecting to SQL Server and running a procedure). I'm wondering why no other procedures in this module run. I place the cursor inside them and press F5, but code execution goes straight to Sub Main and runs that instead. That's what I'm trying to understand.
0
 
LVL 12

Expert Comment

by:ktaczala
ID: 39774736
Set a break point in your code where you want then try debugging it.  Then step through your code my pressing F11

see link:
http://msdn.microsoft.com/en-us/library/y740d9d3.aspx
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:Matti
ID: 39774737
hmm.. you run it twice or multiple  times, are you sure there are no attempts to open a open database and so on, try global declaration or the connection sting.
0
 

Author Comment

by:TimHudspith
ID: 39774755
ktaczala - I did that but code execution jumped straight up to Sub Main, as if the other procedure did not exist.
0
 
LVL 12

Expert Comment

by:ktaczala
ID: 39774928
can you show us what you have in your sub main?  Load Event.
0
 

Author Comment

by:TimHudspith
ID: 39791840
I've requested that this question be deleted for the following reason:

This question stemmed from my unfamiliarity with the Visual Studio environment. What I was aiming at was stepping through procedures in a module by calling them from the Immediate window, which I now know how to do. Apologies for wasting people's time.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 39791828
VB6 was interpreted. It was compiled line by line as you went along in the development environment. It was basically executing your source code.

In VB.NET, the whole application needs to be compiled before you can use the debugger, and you are running over compiled code, not the source code. This changes the way some of the functions of the debugger works, and the Immediate window is one of these.

The use of the Immediate window is mainly to test code while the debugger is active. It can be used as it was used in VB6, but with a few changes.

The procedure should be in a module and be Public. It will run, but only if the application can compile, and only after it has compile, which might take time.

In my opinion, the best way to use it to test procedure is to put a breakpoint right at the start of Main, start the application, and then do you stuff with the Immediate window.

Methods that you call from there will execute on the spot, and can be execute many times without having to wait for the compiler to recompile the application.

And since the application is running, you will have access to methods that are Friend or Private in your module, which is not possible when using the Immediate window while the application is not running.
0
 

Author Closing Comment

by:TimHudspith
ID: 39791841
That's an excellent explanation. Now I understand. Thanks.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question