Railway reservation Project

Error in cancellation form

Page 1 of 1

1 Replies - 4246 Views - Last Post: 15 October 2009 - 06:06 PM Rate Topic: -----

#1 Mythi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 03-February 09

Railway reservation Project

Posted 15 October 2009 - 07:45 AM

I am doing online railway reservation project in VB. In the cancellation form, i am encountering one problem. Here if we click cancel button for expired date no msg is displaying.
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset
Dim sql As String


Private Sub Command1_Click()
sql = "select * from trainres where pnr=" & Text1.Text
If rs.State = 1 Then
rs.Close
End If
rs.Open sql, con, adOpenDynamic, adLockOptimistic
 If (Not rs.EOF) Then
tcount = rs.Fields("trainno")
If (rs.Fields("status") = "Wait Listed") Then
rs.Delete
MsgBox "Ticket Cancelled"
rs.Close

Else

sql = "select * from trainres where status='Wait Listed' and trainno=" & tcount & "and doj in(select doj from trainres where pnr=" & Text1.Text & ")"
If rs1.State = 1 Then
rs1.Close
End If
rs1.Open sql, con, adOpenDynamic, adLockOptimistic
If rs.Fields("doj") < Form2.DTPicker1.Value Then
MsgBox "YOUR DATE HAS EXPIRED"
Text1.SetFocus
Text1.Text = ""
Else
If (Not rs1.EOF) Then
rs1.Fields("status") = "Reserved"
rs1.Update
rs1.Close
rs.Delete
rs.Close
MsgBox "Ticket Cancelled"
End If
End If
End If
End If
End Sub

Private Sub Form_Load()
con.Open "tr"
Text1.Text = ""
End Sub

Private Sub Form_Unload(Cancel As Integer)
con.Close
End Sub




Is This A Good Question/Topic? 0
  • +

Replies To: Railway reservation Project

#2 paperclipmuffin  Icon User is offline

  • Disassembling...
  • member icon

Reputation: 13
  • View blog
  • Posts: 944
  • Joined: 16-April 09

Re: Railway reservation Project

Posted 15 October 2009 - 06:06 PM

Try:

Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset
Dim sql As String


Private Sub Command1_Click()
sql = "select * from trainres where pnr=" & Text1.Text
If rs.State = 1 Then
rs.Close
End If
rs.Open sql, con, adOpenDynamic, adLockOptimistic
 If (Not rs.EOF) Then
tcount = rs.Fields("trainno")
If (rs.Fields("status") = "Wait Listed") Then
rs.Delete
ans = MsgBox ("Ticket Cancelled", vbOkOnly, "Ticket Cancellled")
rs.Close

Else

sql = "select * from trainres where status='Wait Listed' and trainno=" & tcount & "and doj in(select doj from trainres where pnr=" & Text1.Text & ")"
If rs1.State = 1 Then
rs1.Close
End If
rs1.Open sql, con, adOpenDynamic, adLockOptimistic
If rs.Fields("doj") < Form2.DTPicker1.Value Then
MsgBox "YOUR DATE HAS EXPIRED"
Text1.SetFocus
Text1.Text = ""
Else
If (Not rs1.EOF) Then
rs1.Fields("status") = "Reserved"
rs1.Update
rs1.Close
rs.Delete
rs.Close
Dim ans As vbMsgBoxResult
ans = MsgBox ("Ticket Cancelled", vbOkOnly, "Ticket Cancellled")
End If
End If
End If
End If
End Sub

Private Sub Form_Load()
con.Open "tr"
Text1.Text = ""
End Sub

Private Sub Form_Unload(Cancel As Integer)
con.Close
End Sub




Good luck! :)

Edit: I didn't notice there was two! :stupid:

This post has been edited by paperclipmuffin: 15 October 2009 - 06:08 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1