By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,378 Members | 1,453 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,378 IT Pros & Developers. It's quick & easy.


P: 374
hi all

i have got a win app that has 2 screens
SalaryScreen and EmployeeScreen

now i bind the data to a dataTable manually in the code like this.

Expand|Select|Wrap|Line Numbers
  1. Try
  2.             sqlConnection = New SqlConnection("Data Source=DONOVANPC\SQLEXPRESS;Initial Catalog=DemoDB;Integrated Security=True;Pooling=False")
  3.             sqlConnection.Open()
  4.             sqlcommand = New SqlCommand("USE " + My.Settings.sqlDataBaseName + vbCrLf & _
  5.                                         "SELECT * FROM EmployeeDetails", sqlConnection)
  6.             sqlAdapter = New SqlDataAdapter
  7.             sqlAdapter.SelectCommand = sqlcommand
  8.             sqlDataTable = New DataTable
  9.             sqlAdapter.Fill(sqlDataTable)
  11.             ' Bind Controls with datatable
  12.             txtEmployeeCode.DataBindings.Add("text", sqlDataTable, "EmployeeCode", True)
  13.             txtSurname.DataBindings.Add("text", sqlDataTable, "EmployeeSurname", True)
  14.             txtInitials.DataBindings.Add("Text", sqlDataTable, "EmployeeInitials", True)
  15.             txtFirstNames.DataBindings.Add("text", sqlDataTable, "EmployeeFirstName", True)
  16.             cbTitle.DataBindings.Add("Text", sqlDataTable, "EmployeeTitle", True)
  17.             txtNickName.DataBindings.Add("text", sqlDataTable, "EmployeeNickName", True)
  18.             txtPhysAddress1.DataBindings.Add("text", sqlDataTable, "EmployeePhysicalAddress1", True)
  19.             txtPhysAddress2.DataBindings.Add("text", sqlDataTable, "EmployeePhysicalAddress2", True)
  20.             txtPhysAddress3.DataBindings.Add("text", sqlDataTable, "EmployeePhysicalAddress3", True)
  21.             txtPhysPCode.DataBindings.Add("text", sqlDataTable, "EmployeePhysicalPostalCode", True)
  22.             cbGroup.DataBindings.Add("text", sqlDataTable, "EmployeeGroup", True)
  23.             cbGender.DataBindings.Add("text", sqlDataTable, "EmployeeGender", True)
  24.             cbLanguage.DataBindings.Add("text", sqlDataTable, "EmployeeLanguage", True)
  25.             cbMaritalStatus.DataBindings.Add("text", sqlDataTable, "EmployeeMaritalStatus", True)
  26.             txtTelHome.DataBindings.Add("text", sqlDataTable, "EmployeeTelHome", True)
  27.             txtCellNo.DataBindings.Add("text", sqlDataTable, "EmployeeCellNo", True)
  28.             txtTelWork.DataBindings.Add("text", sqlDataTable, "EmployeeTelWork", True)
  29.             txtWorkExt.DataBindings.Add("text", sqlDataTable, "employeeWorkExt", True)
  30.             txtRoomNo.DataBindings.Add("text", sqlDataTable, "EmployeeRoomNo", True)
  31.             txtEmailAddress.DataBindings.Add("text", sqlDataTable, "EmployeeEmailAddress", True)
  32.             txtPostalAdd1.DataBindings.Add("text", sqlDataTable, "EmployeePostalAddress1", True)
  33.             txtPostalAdd2.DataBindings.Add("text", sqlDataTable, "EmployeePostalAddress2", True)
  34.             txtPostalAdd3.DataBindings.Add("text", sqlDataTable, "EmployeePostalAddress3", True)
  35.             txtPCode.DataBindings.Add("text", sqlDataTable, "EmployeePostalCode", True)
  36.             txtID.DataBindings.Add("text", sqlDataTable, "EmployeeIdNumber", True)
  37.             txtPassport.DataBindings.Add("text", sqlDataTable, "EmployeePassportNumber", True)
  38.             cbNature.DataBindings.Add("text", sqlDataTable, "EmployeeNature", True)
  39.             txtTaxNo.DataBindings.Add("text", sqlDataTable, "EmployeeTaxNumber", True)
  40.             dtDateOfBirth.DataBindings.Add("Text", sqlDataTable, "EmployeeDateBirth", True)
  41.             dtEngageDate.DataBindings.Add("Text", sqlDataTable, "EmployeeEngageDate", True)
  42.             dtIRP5Date.DataBindings.Add("Text", sqlDataTable, "EmployeeIRP5Date", True)
  43.             dtPensionStart.DataBindings.Add("Text", sqlDataTable, "EmployeePensionStartDate", True)
  44.             dtProvidentStart.DataBindings.Add("Text", sqlDataTable, "EmployeeProvidentStartDate", True)
  45.             dtMedicalStart.DataBindings.Add("Text", sqlDataTable, "EmployeeMedicalStartDate", True)
  46.             dtRAStart.DataBindings.Add("Text", sqlDataTable, "EmployeeRAStartDate", True)
  47.             dtStudyExpirey.DataBindings.Add("Text", sqlDataTable, "EmployeeStudyExpireyDate", True)
  48.             cbPaymentType.DataBindings.Add("text", sqlDataTable, "EmployeePaymentType", True)
  49.             cbTaxStatus.DataBindings.Add("text", sqlDataTable, "EmployeeTaxStatus", True)
  50.             cbNormalStatus.DataBindings.Add("text", sqlDataTable, "EmployeeNormalStatus", True)
  51.             dtResign.DataBindings.Add("Text", sqlDataTable, "EmployeeResignationDate", True)
  52.             txtResignReason.DataBindings.Add("Text", sqlDataTable, "EmployeeResignationReason", True)
  53.             dtContractExpirey.DataBindings.Add("Text", sqlDataTable, "EmployeeContractExpireyDate", True)
  54.             txtPensionE.DataBindings.Add("text", sqlDataTable, "EmployeePensionEmp", True)
  55.             txtPensionC.DataBindings.Add("text", sqlDataTable, "EmployeePensionCompany", True)
  56.             cbAdultDeps.DataBindings.Add("text", sqlDataTable, "EmployeeMedAdultDeps", True)
  57.             cbChildDeps.DataBindings.Add("text", sqlDataTable, "EmployeeMedChildDeps", True)
  58.             cbPaymentMethod.DataBindings.Add("text", sqlDataTable, "EmployeePayMethod", True)
  59.             txtBranchCode.DataBindings.Add("text", sqlDataTable, "EmployeeBankCode", True)
  60.             txtBankAccNumber.DataBindings.Add("text", sqlDataTable, "EmployeeBankAccNo", True)
  61.             cbAccountType.DataBindings.Add("text", sqlDataTable, "EmployeeBankAccType", True)
  62.             txtArea.DataBindings.Add("text", sqlDataTable, "EmployeeArea", True)
  63.             txtCategory.DataBindings.Add("text", sqlDataTable, "EmployeeCategory", True)
  64.             txtCostCentre.DataBindings.Add("text", sqlDataTable, "EmployeeCostCentre", True)
  65.             txtDepartment.DataBindings.Add("text", sqlDataTable, "EmployeeDepartment", True)
  66.             txtOccupation.DataBindings.Add("text", sqlDataTable, "EmployeeOccupation", True)
  67.             txtPayPoint.DataBindings.Add("text", sqlDataTable, "EmployeePayPoint", True)
  68.             sqlConnection.Close()
  70.             ' Establish Navigation Manager
  71.             sqlManager = DirectCast(Me.BindingContext(sqlDataTable), CurrencyManager)
  72.         Catch sqlexc As SqlException
  73.             MsgBox(sqlexc.Message, MsgBoxStyle.OkOnly, "SQL Exception Error")
  74.         Catch exc As Exception
  75.             MsgBox(exc.Message, MsgBoxStyle.OkOnly, "Connection Failed")
  76.         End Try
  77.         SetText()
  78.     End Sub
the query used is
Expand|Select|Wrap|Line Numbers
  1. USE + My.Settings.sqlDataBaseName + vbCrLf & _
  2.                                         "SELECT * FROM EmployeeDetails", sqlConnection
now i have 2 tables, earnings and employees with a commen column called EmployeeID

now i want to for instance get information from both tables at the same time and update the values of both tables at the same time when im working with the dataTable. the tables information well some of it will need to update each other.

is this possible with a JOIN... ???
Apr 2 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 2,878
Is it possible to update two tables at the same time? Technically, no. Stored proc, batches still has to be processed sequentially (the first statement on the batch has to be executed before the second one). But there are work around: Use view.

Also if you're trying to access table or tables that would require you to build this query, I would recommend you consider views or table-valued functions.

-- CK
Apr 2 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.