Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I have an n-tier app that I am currently migrating from VB6 to VB.Net. My question is what is the best and most efficient way to populate fields on a form. For example if I have a customer form, should I be populating the comboxes for the Company Name, Province, and Country all at form load, or upon the respective Click event of each control.
  • *Experts*
Posted
I would say that popluating on form load would be better, because if you have a lot of data and you wanted to popluate it each time the control is clicked the program the program could freeze for a very short time each time you clicked the control.
Posted
Thanks. My next question is that when saving a record for example a customers information to a relational database I want to save a reference for the country and state, eg US = 1, and NewYork = 3. In my VB6 program I used a function called Get_ID that I created to read the primary/foreign key from the database and then loaded that value into the recordset. In .Net I am using Me.BindingContext(dsCustomer.Tables("Customer")).AddNew() to create a new rexord but am not sure how to change the value of the countries combobox from USA to its related primary key value. Hope this makes sense....
Posted

Here's an example in VB6 here is how I wrote data from a form to a recordset:

 

With rsCustomerDetails

!CompanyName = cboCompanyName

!Address1 = txtAddress1

!Address2 = txtAddress2

!City = txtCity

!Province = objCustomer.clsProvince_ID(cboProvince)

!Country = objCustomer.clsCountry_ID(cboCountry)

!PostCode = txtPostCode

!ContactName = txtContactName

!ContactPhone = txtContactPhone

!ContactFax = txtContactFax

!ContactEmail = txtContactEmail

!Notes = txtNotes

End With

 

In VB.Net I use:

 

cmdNew

 

Me.BindingContext(dsCustomer.Tables("Customer")).AddNew()

 

 

cmdSave

 

Me.BindingContext(Me.dsCustomer.Tables("Customer")).EndCurrentEdit()

Dim dsChanges As DataSet = dsCustomer.GetChanges()

 

 

With no control over what goes to each column in the new row.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...