Hello !
These are my two tables which are named Table1 and Table2 ( I know they aren't good names but I created them hastily)
In table1 , I have following fields
In table2 , I haveCode:[Train_Number], [Train_Name],[Starting_point],[Destination],[Fare]
I want have created a ticket cancellation system in which the user enters his [Tnumber] and [Phone]and his ticket gets cancelled but I want vb to display the confirmation receipt to the user after the ticket has been cancelled . The confirmation receipt should also contain the refundable money which is 20% of the respective train of the passenger .Code:[P_Name],[Age],[Phone],[Train_Name],[Tnumber]
I think I would have to join these two tables to fetch the record [Fare] from Table1 as both the information which users enters are in Table2 . The Table2 also contains the name of the Train so , I think we can join both the tables using this field .
The problem is that I don't know how should I do this . I have searched google also but have not found anything . Please help me . This is my cancellation form code .
Code:Imports System.Data.OleDb Public Class Form5 Public Connstring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = C:\Users\AMEN\Documents\Railway.accdb" Public Conn As New OleDbConnection Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Conn.ConnectionString = Connstring If Conn.State = ConnectionState.Closed Then Conn.Open() End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim emptyTextBoxes = From txt In Me.Controls.OfType(Of TextBox)() Where txt.Text.Length = 0 Select txt.Name If emptyTextBoxes.Any Then MsgBox("Please fill the empty feilds ") Else Dim okToDelete As MsgBoxResult = MsgBox("Are you sure you want to cancel your ticket?", MsgBoxStyle.YesNo) If okToDelete = MsgBoxResult.Yes Then Dim str As String str = "Delete from Table2 Where Phone = '" & TextBox1.Text & "' and Tnumber= " & TextBox2.Text Dim cmd As OleDbCommand = New OleDbCommand(str, Conn) Try cmd.ExecuteNonQuery() cmd.Dispose() Conn.Close() MsgBox("Your Ticket Cancelled Sucessfully ! ") Catch ex As Exception MsgBox(ex.Message) End Try ElseIf okToDelete = MsgBoxResult.No Then End If Form3.Show() Me.Close() End If End Sub




Reply With Quote
