Good day..

i was stuck a moment realizing what went wrong to my project. I'm currently developing a enrollment system. I have 3 tables in my DB namely course_code,curriculum and pre_requisite tables. on the course_code table i have fields course_code(PK),course_desc. on the curriculum table i have but in this table i dont have a PK subj_code,course_code,subj_desc,lect_unit,lab_unit,tot_unit,prerequisite,cur_year,sem in and on the last table which is prerequisite i have subj_code,subj_desc,prerequisite,sem and major field, my course_code on the course_code(PK) table is related to the course_code of the curriculum table, the relation is 1-many, on the other hand subj_code which is from the curriculum table is related to subj_code(PK) of of the prerequisite table, they are related to each other 1-many relation. i have 2 forms which is course_info form and curriculum form. on the course_info i have only 2 textbox which is txtccode and txtcourse_description while on the curriculum form i have many controls a combination of combo box and textbox

okey here's my problem....

everytime i input a record on the course_info form the course_code record is already added to my course_code table and added to the curriculum table, while if i add record to my curriculum table i added a record both from the curriculum and prerequisite table but when i view my curriculum table has 2 record. (i mean the course_code, and the subj_code has place in different rows) how would i insert a record that place in the same rows..

here's my table record
curriculum table

subj_code course_code subj_desc
1
1000 C++

what i want to expect to see is that
subj_code course_code subj_desc
1000 1 C++

can u help me guys.?


here my code..

Dim cmd2 As New OleDb.OleDbCommand
        Try
            con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\jesspr\Desktop\spist_dbase\Database1.accdb"
            con.Open()

            cmd.Connection = con
            cmd2.Connection = con

            'select a record from the course table
            'cmd.CommandText = "select course_code from tbl_course_code where course_code =" & txtCode.Text


            cmd.CommandText = "Insert into tbl_curriculum (course_code,subj_code,subj_desc,lect_unit,lab_unit,tot_unit,cur_year,sem) values(" & txtCode.Text & "," & txtScode.Text & ",'" & txtSdesc.Text & "'," & cmblecUnits.SelectedItem & "," & cmbLabUnits.SelectedItem & ", " & txtTotUnits.Text & ",'" & txtcurYear.Text & "'," & cmbSem.SelectedItem & ")"
            cmd2.CommandText = "insert into tbl_prerequisite (subj_code,subj_desc,Semester) values (" & txtScode.Text & ",'" & txtSdesc.Text & "'," & cmbSem.SelectedItem & ")"



            cmd.ExecuteNonQuery()
            cmd2.ExecuteNonQuery()

            'Dim nr As DataRow = tbl.NewRow
            'nr("subj_code") = txtScode.Text
            'nr("subj_desc") = txtSdesc.Text
            'nr("lect_unit") = cmblecUnits.SelectedItem
            'nr("lab_unit") = cmbLabUnits.SelectedItem
            'nr("sem") = cmbSem.SelectedItem
            'nr("cur_year") = txtcurYear.Text

            'tbl.Rows.Add(nr)
            'adapter1.Update(tbl)
            'rpos = tbl.Rows.Count - 1

            MessageBox.Show("One record has been added", "Add record")
            'adapter1.Update(tbl)
        Catch ex As Exception
            MessageBox.Show(ex.Message & "add record")
        Finally
            txtScode.Text = ""
            txtSdesc.Text = ""
            cmblecUnits.Text = ""
            cmbLabUnits.Text = ""
            cmbSem.Text = ""
            txtcurYear.Text = ""
            txtTotUnits.Text = ""

            con.Dispose()
        End Try

    End Sub

even though no one help me about this problem.. i already solve this a day after i post it here. by the way thanks to all..

lp me about

can you share the solution to this problem? Im encountering it also.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.