Monday, June 29, 2009
What is different between Classic ADO and ADO.NET?
in ADO.NET there is no such Cursors but here one can uses similar kind of functionality which is provided by Datasets
What is ADO.NET in VB.NET?
Ther are 5 Components of ADO.NET which are as follows:-
Connection
Command
Data Reader
Data Adapter
Data Set.
Connection:-
Both SqlConnection and OledbConnection namespaces can be inherited. if you are working with sql Server then you need SqlConnection..in all other cases you need to use OledbConnection. this connection object established the connection to database. which is then use to retrive data to datareader from database. It has a property named connectionstring is the main property which helps to connect with database which one wants. there are methods like Open() which helps to open the connection to retirve data and after retirvation Close() method is used for closing a connection, one can check the connection status with state property.
Command:-
There are some methods to execute command which depends on the situation what we need as and output. name of methods are as follows:-
ExecuteReader()
ExecuteScalar()
ExecuteNonQuery()
now here ExecuteReader() method will return all the data which on need and which is written as command and which will go to the object of datareader.
ExecuteScalar() is used when one need to insert a row and want to know the primary key value of that current inserted row, so here ExecuteScalar() will return the primary key value of the inserted row.
ExecuteNonQuery() is used when no output is needed. this happens when one fires update and delete query.
DataAdapter:-
Dataadapter is very useful in connectivity. it helps and provide relationship between Datasource and Datasets.
when one need to access the data and store that in dataset so with the help of dataadapter one can fetch the data and store that in the dataset and afterwords it can b used later form dataset.
Dataadapter uses four different methods to manage data i.e. select, insert, update and delete.
now here is the code to manipulate dataset using dataadapter.
first of all we have to create the object of dataadapter.
Dim dadapter As OleDbDataAdapter = new OleDbDataAdapter
Dim dset As OleDbDataSet = new OleDbDataSet
now once object of dataadapter and dataset are created so now one can load dataset using dataadapter fill() method
dadapter.fill(dset,#)
here # will replace with the object of dataTable name from where the data is to be bring.
now after modifing anything one can use one of the above methods like update to update the datasource from the dataset.
Sunday, June 28, 2009
How to create our own Control in VB.NET?
now open ur VB.NET professional or enterprise edition which ever u have. now select 'New project' from file menu and from there Select Windows Forms Application or Empty Project From Templates...name it(textbox) and then press ok button...now from Solution Explorer right click on main project i.e. textbox(if you have given same name) and select properties option from popup menu.
now from Application tap select Class Liberary as Application type(We are doing this because we want to get output as a dll file not as a windows application.
now again from solution explorer right click on project name and select 'User Control' from Add menu. name it my_textbox.vb and press Add button to add that control, now you will be able to see that control in solution explorer.....now just start the code view of that control
which seems like
"Public Class my_textbox"
"End Class"
now you need to do is just write a line to include the textbox class which you want as a control(not necessary only textbox but you can choose any control form there.)
"Inherits system.windows.forms.textbox" and save it.....
it will look like this
"Public Class my_textbox"
"Inherits system.windows.forms.textbox"
"End Class"
now just go to desigh view again...it will show some errors...dontworry about that...just ignore that and just click on continue.....
now Click on Build My_textbox form build menu......after building it successfully, just go to the location of source folder there you can see onw textbox.dll file in Release folder. so that is what you want......
now open another windows application...now what you need to do is just drag and drop that dll file in the toolbox of that application...you can see now that a contorl named my_textbox is added in it.....now just use that as ur control......
note: like this control you can create your own control which includes properties and methods which you want to include and you can make a control like validate textbox which accepts only email or numbers or letters in that textbox which you want......
Saturday, June 27, 2009
VB.NET is useful for shareware applications?
Difference between versions?
in version 2003 framework version 1.1 is used
in version 2005 framework version 2.o is used
in version 2008 framework version 3.5 is used
in version 2003 there was no facility of changing code during debugging mode but in version 2005 and 2008 there is facility to change the code during debugging is going on.