Search VB 2010

Showing posts with label Visual Basic 2010. Show all posts
Showing posts with label Visual Basic 2010. Show all posts

Wednesday, August 03, 2016

.Net framework 4.5.2 for Visual Studio 2010

.Net framework 4.5.2 for Visual Studio 2010
Visual Basic 2010 Advanced Compiler
Visual Basic 2010 Advanced Compiler
If you have installed Visual Studio 2010 on Windows 7, 8, 10 recently, you will notice that you have all .Net Framework versions available, and you will notice also that you Windows updates .net framework versions to a higher versions (i.e. If you have .net framework 4, windows will update this to 4.5) but you won't find .net framework v4.5 in your Visual Studio 2010, why ?!

Because targeting .net framework 4.5 via Visual Studio 2010 Each version of VS prior to Visual Studio 2010 is tied to a certain .NET framework. (VS2008 is .NET 3.5, VS2005 is .NET 2.0, VS2003 is .NET1.1) VS2010 and beyond allow for targeting of prior framework versions but cannot be used for future releases. You must use Visual Studio 2012 in order to utilize .NET 4.5.

Sunday, May 01, 2016

VB 2010 with MS Access 2010 Error Conversion from type 'DBNull' to type 'String' is not valid.

Conversion from type 'DBNull' to type 'String' is not valid.
Error :
Conversion from type 'DBNull' to type 'String' is not valid.
Cause :
Trying to Fetch Data From empty database table field
Solution :


Here are some online Visual Basic lessons and courses :

Sunday, December 15, 2013

Visual Basic Compare Two Treeviews and return differences

Visual Basic 2010 - Compare Two Strings and return differences and matches

vb2010 compare strings and return differences
VB2010 Compare Strings in Collections

Collections as an Alternative to Arrays

Visual Studio 2010
Although collections are most often used for working with the Object Data Type, you can use a collection to work with any data type. In some circumstances, it can be more efficient to store items in a collection than in an array.



If you need to change the size of an array, you must use the ReDim Statement (Visual Basic). When you do this, Visual Basic creates a new array and releases the previous array for disposal. This takes execution time. Therefore, if the number of items you are working with changes frequently, or you cannot predict the maximum number of items you need, you might obtain better performance using a collection.

A collection, which does not have to create a new object or copy existing elements, can handle resizing in less execution time than an array, which has to use ReDim. But if the size does not change, or changes only rarely, an array is likely to be more efficient. As always, performance is highly dependent on the individual application. It is often worth your time to try both an array and a collection.

This Example

How to compare two Treeviews in VB2010
How to return the differences between two Treeviews

Solution

- Create Visual Basic 2010 Windows Application Project
- On Form1, place two tree views and two textboxes and one button

Visual Basic Online Course
Visual Basic 2010 Compare Strings from Treeview
How does it work ?
- Store the Treeview1 [TRV1] nodes into Textbox, and the same with Treeview2 [TRV2]
- How many strings [Lines] in each Textbox

  • We want to find where both Textboxes is different and where both Textboxes is match to one another. For example, differences are :
- TRV1 has an extra string [Southern American]
- TRV2 node string [Africa] is different from TRV2 node string [African]

Steps to accomplish this task :





Download example from Mediafire
Extended work :
You can easily extract any Database tables, columns Schema into a treeview control, and you can also using this example compare two tables or two columns in a Database using this example as well.

You can use ListViews or ComboBoxes or ListBoxes instead of the Treeview control, I used the treeview control because it's always tricky to work with. Using other controls that store strings in Collection format would be so easy, even much easier than using Treeviews.

Another Treeview Examples

Expand and Collapse two treeviews at the same time according to one another even if they both don't have the same nodes names. Expand TreeView1[TRV1] node when TreeView2 [TRV2] node is expanded or collapsed.

TreeView Example : Change the node font

TreeView Example : Add a photo (icon) to the TreeView
1) Add ImageList from the ToolBox
2) Add 2 photos to the ImageList1 [From properties, Collection], for example :
- Photo1.Png (Index by default is Zero 0), this will be the Parent icon
- Photo2.Png (Index by default is One 1), this will be the first child icon
3) Code to display image/Icon in the Tree View :


Here are some online Visual Basic lessons and courses :

Friday, December 09, 2011

Solution - There is already an open DataReader associated with this Command which must be closed first.

VB 2010

Problem : There is already an open DataReader associated with this Command which must be closed first.
Cause : Having more than 1 dataReader result set working at the same time .
Solution : In my solution example, i work with SqlServer2000 and VB.Net 2005 
The Example Project can be downloaded at the end of this post :
It contains (SqlServer2000 DataBase - VB.Net Project)
The example shows how to navigate (First Record - Next Record) using ADO.Net 2.0 Online-Mode using SqlClient DataReader ...
Sql Database Name : Market
Sql Database Table : Market.Info
Server Name : evry1falls
(in order to see the example correctly, you'll have to Import the Database 'Market' into your sqlserver2000 Enterprise Manager)
Photo1 : Application Final Design
Photo 1












Photo2 : Table Structure
Photo 2







Photo3 : Codes
Photo 3






Photo4 : Codes
Photo 4







Photo5 : Codes
Photo 5








Now if you run the project and tried to navigate using (First) or (Next) you will get the Exception :
There is already an open DataReader .....
so the solution would be :
Trap the Exception that shows in the (SelectedIndexChanged) Event of the (ComboBox) like this :

and the same for the (Next) Button ..
now you can Navigate and search using combobox safely without exceptions ..

Note :
- Source code will give you exception and you will have to re-write the solution by yourself  as shown above .
- The Folder(Bin/Debug) Includes (Back-Up) use it to restore the (Market Database) in your sqlserver2000
- use the namespace (evry1falls) as new server Registration .

Download Source Code : MediaFire Link

Using MS Access 2003/2007/2010

- In case of using Microsoft Access Database, OleDb.OleDbDataReader with OleDb.OleDbCommand.

The work around or the solution would be :
Always create a new Instance of the OleDbCommand, I.e

Visual Basic Courses - Share