Visual Basic .NET Tutorial

Solution to “System.Data.InvalidConstraintException: ForeignKeyConstraint” error

Submitted by admin on
If you encounter the following error: System.Data.InvalidConstraintException: ForeignKeyConstraint FK_foreign_key_name requires the child key values (-1) to exist in the parent table. Or The INSERT statement conflicted with the FOREIGN KEY constraint "FK_foreign_key_name ". The conflict occurred in database "YourDatabase", table "dbo.Tablename", column 'YourPrimaryKey'. The statement has been terminated. Probably you are using a Parent-Child table or Master-Detail table.

SQL server 2008 Save,Edit,Delete and Search from Datagridview Vb.net 2008

Submitted by princenathan on
Imports System.Data Imports System.Data.SqlClient Public Class frmRID Dim sCommand As SqlCommand Dim sAdapter As SqlDataAdapter Dim sBuilder As SqlCommandBuilder Dim sDs As DataSet Dim sTable As DataTable Private Sub cnew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cnew.Click Call main() Con.Open()

Connect to SQL Server 2008 through TCP / IP Using VB.NET 2008 Project

Submitted by princenathan on
Hi this is Vb.net connect sql server using TCP/IP before run this program you need to install a vb.net 2008 and sql server 2008 here in example code: Hi you need to do this click all program/ ms sql server 2008 / configuration tool then click SQL server configuration manager select you server name then rigth click properties you need to enable a TCP and IP add then Restart

How to Store Data Under %appdata% Using Visual Basic .NET

Submitted by admin on

Sometimes we need to store some data or files under %appdata%. If you are using Windows 7 you can find this folder under C:\Users\Username\AppData.

AppData is a folder used to store information like cookies, Libraries, program settings, temporary files, templates, etc.

By using this folder you are certain that your settings are being protected by Windows.

To access this folder, all you have to do is use the following code:

How to Open Cash Drawer using VB.NET

Submitted by admin on
I just want to share with you the code that I have found on the internet on how to open a Cash Drawer using VB.NET. I am in no way claim this code as my own work. I want to share this with you because there’s a lot of question on the internet on how to open a Cash Drawer on VB.NET. The code will simply open the cash drawer using either the LPT port or COM port.

How to Calculate Two Columns in DataGridView

Submitted by admin on

In my previous tutorial using DataGridView Control I explained on “How to Differentiate Two Cell Values in DataGridView Control”. This time I will teach you on how to calculate two columns in DataGridView Control.

This tutorial is very useful if you want to make a total of the two columns. For example a total of “Qty” and “Sales Price” Column.

Additionally, we will make a total of the “Amount” column.

How to Create Reports using Crystal Reports

Submitted by admin on

This tutorial will teach you on how to create reports in Visual Basic .NET 2008 using Crystal Reports. This is a step by step guide on how I create the report on "Weekly Sales Report using Crystal Reports".

This guide is not intended for advance user. So please don't react if you find a basic explanation on this tutorial.

This assumes that you have already attached the database that is included in the zip file of "Weekly Sales Report ".

How to Change Connection String of VB.NET Project at Design Time

Submitted by admin on

One of the problems that a beginner encounter when there is a project uploaded here, is they do not know on how to change the connection string that points to the correct database location. This is true with MS Access and even with SQL Server. Some programmers don’t add a code that will automatically change the location of the database just in case it will be ported in other machine.