1.11M Members

Gym membership project - Help please

 
0
 

Im currently making a type of gym membership software using vb.net as the front end and access database to store the records.

Ive been working on this for the past few weeks, ive been battling errors and complications all the time, and im getting to the point where the deadline is looming as its a college project.

Im not expecting answers or anyone to to do the work, i would appropriate if anyone could give me hints or point me in the right directions.

Ive had success at updating one form with data but as its a membership system i need to be able too update two forms on the same vb page.

One for there details such as name, age etc.
The other for there membership details
Here is the code for my update button

Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click

        Dim cb As New OleDb.OleDbCommandBuilder(da)
        inc = 1

        sql = "Select * FROM members"
        da = New OleDb.OleDbDataAdapter(sql, con)
       
        ds.Tables("members").Rows(inc).Item(1) = txtFirstname.Text
        ds.Tables("members").Rows(inc).Item(2) = txtsurname.Text
        ds.Tables("members").Rows(inc).Item(3) = txtDateofbirth.Text
        ds.Tables("members").Rows(inc).Item(4) = txtAddress.Text
        ds.Tables("members").Rows(inc).Item(5) = txtPostcode.Text
        ds.Tables("members").Rows(inc).Item(6) = txtTelephone.Text
        ds.Tables("members").Rows(inc).Item(7) = txtGender.Text
        ds.Tables("members").Rows(inc).Item(8) = txtemail
      [B]  da.Update(ds, "members")[/B]

Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
       
 ds.Clear()
        da.Fill(ds, "members")



        sql = "Select * FROM payments"
        da = New OleDb.OleDbDataAdapter(sql, con)
        ds.Tables("payments").Rows(inc).Item(1) = txtpayment.Text
        da.Update(ds, "payments")
        ds.Clear()
        da.Fill(ds, "payments")

       

       
    End Sub

Could anyone give me any suggestions please
Thanks

 
0
 
....
        inc = 1

        sql = "Select * FROM members"
        da = New OleDb.OleDbDataAdapter(sql, con)
        Dim cb As New OleDb.OleDbCommandBuilder(da)
 ....
 
0
 

Thanks for the input im getting the There is no row at position 1. error which ive had few times before.

I was wondering if anyone could help me on my search page, im trying to get the page to search for the users ID number which is imputed eg 1,2,3.

From here the user then presses the search button and the members first and last names are displayed.

Private Sub Txtsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Txtsearch.Click

        cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=J:\Database2.mdb;") 
        cn.Open()

        strSearch = "Select * from members"
        cmd = New OleDbCommand(strSearch, cn)

        dr = cmd.ExecuteReader

        While dr.Read
          [B]  If dr(0) = Txtsearch.Text Then[/B]
"Conversion from string "Search" to type 'Double' is not valid."
                txtfname.Text = dr(1)

                txtlname.Text = dr(2)


            End If
        End While
        cn.Close()
        dr.Close()
    End Sub
End Class

From my understanding is the error occurring because i am entering a number to search for then wanting to return actual character values. Or is it becuase the search feilds are empty. or am i totally missing the point.
thanks for any advice

 
0
 

if dr(0).ToString() =Txtsearch.Text
or
if dr(0)=val(Txtsearch......

 
0
 

Thanks for that, the errors have stoped, now ive just got to get it to return some values

 
0
 

Managed to fix this with some help from a tuter.

rivate Sub Txtsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Txtsearch.Click
        Dim test As Integer
        cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=I:\Database2.mdb;")
        cn.Open()
        Dim strSearch As String
        strSearch = "Select * from members"
        cmd = New OleDbCommand(strSearch, cn)
        dr = cmd.ExecuteReader
        test = 0
        'Val(Txtsearch.Text)
        While dr.Read
            test = dr(0)
            If test = Val(TextBox1.Text) Then


                txtfname.Text = dr(1)

                txtlname.Text = dr(2)
            End If

        End While
        cn.Close()
        dr.Close()
    End Sub
End Class

Might come in handy for anyone wanting to serach a accsess database from vb.net

 
0
 

im sorry its just visual basic

Public Class healthclubmembership


    Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
        Me.Close()
    End Sub

    Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
        Me.txtnewmember.Text = " "
        Me.txtnumberofprepaymonths.Text = " "
        Me.lblpaymentamount.Text = " "
        Me.RadioButton1.Checked = True
        Me.RadioButton2.Checked = False
        Me.RadioButton3.Checked = False
        Me.txtnumberofprepaymonths.Focus()


    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub btncalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalculate.Click

        Dim decnumberofprepaymonths As Decimal
        Dim deccostpermembership As Decimal
        Dim deccostcalculated As Decimal
        Dim decSingleMembershipCost As Decimal = 38D
        Dim decFamilyMembershipCost As Decimal = 58D
        Dim DecSeniorMembership As Decimal = 27D


        If IsNumeric(Me.txtnumberofprepaymonths.Text) Then
            decnumberofprepaymonths = Convert.ToDecimal(Me.txtnumberofprepaymonths.Text)

            If decnumberofprepaymonths > 0 Then

                If Me.RadioButton1.Checked Then
                    deccostpermembership = decSingleMembershipCost
                ElseIf Me.RadioButton2.Checked Then
                    deccostpermembership = decFamilyMembershipCost
                ElseIf Me.RadioButton3.Checked Then
                    deccostpermembership = DecSeniorMembership

                End If

                deccostcalculated = decnumberofprepaymonths * deccostpermembership
                Me.lblpaymentamount.Text = deccostcalculated.ToString("")

            Else
                MsgBox("you entered" & decnumberofprepaymonths.ToString() & "Enter a valid number.", , "Input Error")
                Me.txtnumberofprepaymonths.Text = ""
                Me.txtnumberofprepaymonths.Focus()

            End If

        Else
            MsgBox(" enter a valid number of prepay months ", , "invalid")
            Me.txtnumberofprepaymonths.Text = " "
            Me.txtnumberofprepaymonths.Focus()

        End If



    End Sub
    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click


    End Sub

    Private Sub txtnewmember_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtnewmember.TextChanged

    End Sub
End Class
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article