Well alright so far as maybe some of ya guys might know i am stuck doing project during summer.
Any way i tried going into the college each time and it turns out the college was doing major construction on labs etc... So getting a lab with the appropriate software is near to impossible as i have just found that out last Friday!
Any way since i have to present the project in the college i have to use two programs in conjunction with each other to make my database to work.
Alright to the main route. Hope someone can help.
If i remember one main problem is when i run add member form for example. it wont update to the database or connect. I run debugging and the problem occurs in my INSERT statement.
Here is my entire code and hope someone can help me in sorting out this problem. I am trying to figure out a solution like perhaps try a "Try and Catch" statement but not sure if it will work entirely since i don't have the appropriate software at home.
Private Sub cmdAddMem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddMem.Click
'open database
OpenDB(conn)
'retrieve the max MemId assigned
strSQL = "INSERT INTO Members VALUES ('" + txtMemNo.Text + "','" + _
txtname1.Text + "','" + txtsurname.Text + _
"','" + txtAddress.Text + "','" + txtTown.Text + _
"','" + txtCounty.Text + "'," + txtHomeNo.Text + _
"," + txtMobileNo.Text + ",'" + gender.ToString() + "', 0)"
'determine if the user entered a blank in any of the fields
cmd.Connection = conn
cmd.CommandText = strSQL
cmd.CommandType = CommandType.Text
cmd.ExecuteReader()
MessageBox.Show("Member Created")
'call clear form Method
clearForm()
' Message Box yes no add another member
Dim NewMember As Integer
'Output a messagebox that alerts the user that the details are being saved to the databse
NewMember = MessageBox.Show("Saving Member", "Member", MessageBoxButtons.YesNo, _
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
'If yes call clear form
If NewMember = DialogResult.Yes Then
'clearForm()
clearForm()
ElseIf NewMember = DialogResult.No Then
' If No close form
End
End If
'Update Member id field
End Sub
Entire code
Imports Oracle.DataAccess.Client
Public Class frmNewMem
Dim Main As New frmMain
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
Private Sub cmdAddMem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddMem.Click
'open database
OpenDB(conn)
'retrieve the max MemId assigned
strSQL = "INSERT INTO Members VALUES ('" + txtMemNo.Text + "','" + _
txtname1.Text + "','" + txtsurname.Text + _
"','" + txtAddress.Text + "','" + txtTown.Text + _
"','" + txtCounty.Text + "'," + txtHomeNo.Text + _
"," + txtMobileNo.Text + ",'" + gender.ToString() + "', 0)"
'determine if the user entered a blank in any of the fields
cmd.Connection = conn
cmd.CommandText = strSQL
cmd.CommandType = CommandType.Text
cmd.ExecuteReader()
MessageBox.Show("Member Created")
'call clear form Method
clearForm()
' Message Box yes no add another member
Dim NewMember As Integer
'Output a messagebox that alerts the user that the details are being saved to the databse
NewMember = MessageBox.Show("Saving Member", "Member", MessageBoxButtons.YesNo, _
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
'If yes call clear form
If NewMember = DialogResult.Yes Then
'clearForm()
clearForm()
ElseIf NewMember = DialogResult.No Then
' If No close form
End
End If
'Update Member id field
End Sub
Private Sub btnMale_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMale.CheckedChanged
'determine if the button clicked is male or female
If btnMale.Checked = True Then
gender = "m"
Else
gender = "f"
End If
End Sub
Private Sub MainToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MainToolStripMenuItem.Click
Me.Hide()
Main.Show()
End Sub
Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
frmMain.Show()
Me.Close()
End Sub
Private Sub frmNewMem_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtMemNo.Text = LastMemNo() + 1
End Sub
Private Function LastMemNo() As Integer
'connect to database
OpenDB(conn)
'retrieve the max MemId assigned
Dim strSQL As String = "SELECT MAX(ID) as MaxID FROM Members"
'execute SQL query
Dim cmd As New OracleCommand
cmd.Connection = conn
cmd.CommandText = strSQL
cmd.CommandType = CommandType.Text
Dim dr As OracleDataReader = cmd.ExecuteReader()
dr.Read()
If IsDBNull(dr.Item(0)) Then
conn.Close()
Return 0
Else
Return dr.Item("MaxId")
End If
End Function
Private Function clearForm() As Integer
'clear all fields
txtHomeNo.Text = ""
txtMobileNo.Text = ""
txtname1.Text = ""
txtsurname.Text = ""
txtTown.Text = ""
txtCounty.Text = ""
txtAddress.Text = ""
Return 0
End Function
End Class
Any way don't advise me on alternatives such as asking lecturer coz she is on holiday at this stage or taking other transport into the college or finding other downloads etc... coz it might spark up an argument.
This is the code i got on my hard-drive but i could have been working off a copy on my college hard-drive.

New Topic/Question
Reply




MultiQuote










|