ehrendreich 0 Newbie Poster

Hi, check this link. Its all there.

I will check that out.

ehrendreich 0 Newbie Poster

Oops no city string in the tblMembers table

ehrendreich 0 Newbie Poster

I have 3 tables in MSSQL 2008 (ABSTRACT)

tblContacts:
ContactID: Auto Numbering Int
FName: string
LName: string
Address1: string
Address2: String
City: string
State: string
Zip: string
ContactType: int


tblStaff:
ContactID: int
StaffID: AutoNumber Int
Title: string
Unit: string
(etc)


tblMembers:
ContactID int
ApplicationDate: string
Membership Date: date/time
City: string
StaffID: string
Unit: string
(etc)

Actually this represents an example that is greatly simplified. I have been looking to create a windows form that binds this data to textboxes and such. The master table is the tblContacts and detail is tblMembers:. The relationship is based on ContactID and each tblMembers has an associated record from the tblStaff which will needs to return the first name and last name of the staff person that is assigned to the member.

I need to use mostly all text boxes or comboxes and there are a lot of fields that have to go into the tblMembers table. I have been using tabs to segment the detail areas for the member information because of the amount of real estate that all of the fields that is taken up.

I can get the tblContacts fields to add a new record but any information that is added to the tblMembers table is lost. If I navigate to another record and come back the data …

ehrendreich 0 Newbie Poster

I am having a problem trying to save records in a parent / child data relation. I have to tables tblContacts & tblMember. There is a fk relation on the ContactID field. The tblContacts table is the master record. I am using a set up bound windows forms controls to do the data collection. The problem that I am having is in saving the child record. After the form is populated in both the fields and hitting the save button the items in the child record get deleted. It does add a row in the child record but only the ContactID (from the master table) and the key for the tblMember table.

I can see that since the new master record incites the addition of a new row, the data is abandoned. Once there is a save done to the master / child record I can go back and modify the fields and it saves it successfully. I know I must be missing something small. I am not sure how to work around this so that the controls are read into memory and then completed in the new row. I have an example of my code:

Private Sub TblContactsBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblContactsBindingNavigatorSaveItem.Click

        Dim newMemberRow As DataRow 'To create a new row in the tblMember table
        Dim contactID As Integer 'To hold the contactID to insert in the new member ContactID field
        Dim rowsaffected As Integer 'To indicate the number of rows affected …
ehrendreich 0 Newbie Poster

Ok. I found out that to get the insert done this way you have to reset the bindingsource. As in

Me.TblContactsBindingSource.ResetBindings(True)
ehrendreich 0 Newbie Poster

I have a windows form that references two tables with a foreign key constraint issue. This form uses detail views for both tables. The tables are tblContact and tblMembers. The relation is based on the ContactID that is in both tables. The parent is in the tblContact table.

I am using the binding source to do record navigation. Overall this is working well. When I have data in both tables it performs navigation accurately. Modification works if there is existing data in both tables that meet the relationship. The problem that I have is when I try to find if there is an existing record in the tblMembers table. I can't use find. I know that it has to do with accessing the detail table correctly. I am pretty sure that this is done via getting the properties of the table and accessing the PropertyDescriptorCollection.

Either way I am looking to save the data in the tables in a safe way. I am also concerned that I might have concurrency problems with the way that I am getting records.

Here is a code example that I am trying:

Imports System.ComponentModel

Public Class frmMember

    Private Sub TblContactsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Validate()
        Me.TblContactsBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.Ds)

    End Sub


    Private Sub TblContactsBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblContactsBindingNavigatorSaveItem.Click

        Dim newMemberRow As DataRow 'To create a new row in the tblMember table
        Dim contactID As Integer 'To hold the contactID to insert in the new …
ehrendreich 0 Newbie Poster

It is a combo box. I must have grabbed the wrong section of code. I got it later last night. Thanks for asking.

I am working on validating a combo box. This does have a list of possible values but also allows for editing. So for example if the user does not select one of the available cities in the list they can type it in.

I have tried using the validation event but I seem to not begetting it.

ie...


Private Sub txtAddress1_Validating(ByVal sender As Object, ByVal _
e As System.ComponentModel.CancelEventArgs) Handles _
txtAddress1.Validating
'Check to see if the first name textbox is empty

If CType(sender, TextBox).Text = "" Then
MessageBox.Show("The first line of the address is required.", "Required Information", MessageBoxButtons.OK, MessageBoxIcon.Warning)
e.Cancel = True
End If

End Sub

ehrendreich 0 Newbie Poster

I am working on validating a combo box. This does have a list of possible values but also allows for editing. So for example if the user does not select one of the available cities in the list they can type it in.

I have tried using the validation event but I seem to not begetting it.

ie...


Private Sub txtAddress1_Validating(ByVal sender As Object, ByVal _
e As System.ComponentModel.CancelEventArgs) Handles _
txtAddress1.Validating
'Check to see if the first name textbox is empty

If CType(sender, TextBox).Text = "" Then
MessageBox.Show("The first line of the address is required.", "Required Information", MessageBoxButtons.OK, MessageBoxIcon.Warning)
e.Cancel = True
End If

End Sub

ehrendreich 0 Newbie Poster

I am rather new to vb and could use some help. I am using the latest version of vb and am working with a database to add some records. Simply, I would like to have a form that adds a new record into the tblContact table then enter a few fields into the tblContactLog table. The tblContactLog table is tied to the tblContact table with a key called ContactID.

tblContact     tblContactLog


ContactID      ContactID
FirstName      ContactPurpose
LastName       ContactNotes

I realize that I have to create the contact in the tblContact table first. Then I need to read that ContactID from the current record. After I read that value from the current record I need to open the tblContactPurpose table and insert a new record with the ContactID from previous operation.

I have an existing dataset called Clubhouse_Management_SystemDataSet that contains both tables. I have 2 table adapters. One is called TblContactTableAdapter & the other is TblContactLogTableAdapter. For each there is also a binding source. One is TblContactBindingSource and the other TblContactLogBindingSource.

When the form loads I have it filling the table adapters with

'TODO: This line of code loads data into the 'Clubhouse_Management_SystemDataSet.tblContactLog' table. You can move, or remove it, as needed.
Me.TblContactLogTableAdapter.Fill(Me.Clubhouse_Management_SystemDataSet.tblContactLog)
'TODO: This line of code loads data into the        'Clubhouse_Management_SystemDataSet.tblContact' table. You can move, or remove it, as needed.
Me.TblContactTableAdapter.Fill(Me.Clubhouse_Management_SystemDataSet.tblContact)
TblContactBindingSource.AddNew()

I have a button (btnAdd) that does

    TblContactLogBindingSource.EndEdit()
    TblContactTableAdapter.Update(Clubhouse_Management_SystemDataSet.tblContact)
    TblContactLogBindingSource.AddNew() 

This is where I get stuck I need to take the …