Professional Documents
Culture Documents
Interview
Interview
Interview
2)CTS
CTS provides a type system that is common across all languages.CTS defines how data types are
declared,used,&managed in the code during runtime.It also defines rules that ensures that the
data types of object written in various languages are able to interact with each other.
In ado we don't have providers to get connection with database and also we don't have classes
like DataSet and dataadapter.
whereas in ado.net we have providers like MSDAORA.1 for oracle server and
DAMYSQL for MYSQL server to get connection with oracle and mysql server.
4)strong name
Strong Name is required to register the assembly into GAC. Conatins the assembly name,
versoin etc. info.
5)Assemblies are similar to dll files. Both has the reusable pieces of code in the form of classes/
functions. Dll needs to be registered but assemblies have its own metadata. Two types of
assemblys: Shared assembly and private assembly.
Debugging your code is something you will need to do. Unless you write perfect code
every time, there's no getting away from it. In this section, we'll take a look at ways you
can track down errors using VB.NET.
Types of Error
Programming errors are generally broken down into three types: Design-time, Runtime, and
Logic errors.
A Design-time error is also known as a syntax error. These occur when the environment you're
programming in doesn't understand your code. These are easy to track down in VB.NET,
because you get a blue wiggly line pointing them out. If you try to run the programme, you'll get
a dialogue box popping up telling you that there were Build errors.
Runtime errors are a lot harder to track down. As their name suggests, these errors occur when
the programme is running. They happen when your programme tries to do something it shouldn't
be doing. An example is trying to access a file that doesn't exist. Runtime errors usually cause
your programme to crash. If and when that happens, you get the blame. After all, you're the
programmer, and you should write code to trap runtime errors. If you're trying to open a database
in a specific location, and the database has been moved, a Runtime error will occur. It's your job
to predict a thing like this, and code accordingly.
Logic errors also occur when the programme is running. They happen when your code doesn't
quite behave the way you thought it would. A classic example is creating an infinite loop of the
type "Do While x is greater than 10". If x is always going to be greater than 10, then the loop has
no way to exit, and just keeps going round and round. Logic errors tend not to crash your
programme. But they will ensure that it doesn't work properly.
To open up a text file, you need to create something called a "StreamReader". This, as its name
suggests, reads streams of text. The StreamReader is an object available to System.IO. You
create a StreamReader like this:
The first line just sets up a string variable called FILE_NAME. We store the path and name of
our text file inside of the string variable:
= "C:\test.txt"
We're saying that there is a text file called test which is at the location (path) "C:\".
You set up the StreamReader to be a variable, just like a String or Integer variable. But we're
setting up this variable differently:
We've called the variable objReader. Then, after the "As" word comes "New". This means
"Create a New Object". The type of object we want to create is a StreamReader object:
System.IO.StreamReader
Sysytem is the main object. IO is an object within System. And StreamReader is an object
within IO.
StreamReader needs the name of a file to Read. This goes between a pair of round brackets:
System.IO.StreamReader(FILE_NAME)
VB will then assign all of this to the variable called objReader. So instead of assigning say 10 to
an Integer variable, you are assigning a StreamReader to a variable.
Read To End
But this won't do you any good. We haven't actually opened the text file yet. We've just told VB
where the text file is and what object to open it with. You do the opening like this:
TextBox1.Text = objReader.ReadToEnd
Now that objReader is an object variable, it has its own properties and methods available for use
(in the same way that the textbox has a Text property).
One of the Methods available to our new StreamReader variable is the ReadToEnd method. This
will read the whole of your text, right to the end. We're then popping this in a textbox.
TextBox1.Text = objReader.ReadToEnd
objReader.Close()
The last line closes the StreamReader we set up. You have to close your stream objects after
you’ve used them, otherwise you’ll get errors messages.