473,320 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Vb 2008

Apologies if this is a basic question but I am a newbie to VB. I have tried many searches but find it difficult to find a fitting answer.

I am creating a VB 2008 project with SQL 2000 back end.

I have a data source setup, table adapter etc and have populated a form with various fields from the dataset.

I can add records to the DB no problem, however:

What is the correct VB 2008 syntax to populate fields that are not on the form prior to saving the record.

e.g. I have employee ID, First Name, Last Name etc whcih the user enters onto a windows form, but there is a field called hotel ID which the user should not need to populate as this is ascertained from the users login Id.

I have sucessfully created a variable that holds this number @hotelno but don't know how to transfer this value to the SQL field. I wanted something like

hotelno = (Employeesdataset.Tables(1).Rows.Item(0).Item("hot elid"))

I know my syntax is all to cock, but hopefully you understand what I am trying to do.

I think I am wrong in that I cannot address the dataset as this is a new record I am creating and therefore it doesn't exist in the dataset yet.

Any help will be much appreciated
Jul 6 '08 #1
3 1026
OuTCasT
374 256MB
Expand|Select|Wrap|Line Numbers
  1. Dim sqlConnection As SqlConnection
  2. sqlconnection = New sqlConnection("")
  3.  
  4. 'Commands and adapter for the Employee masterfile
  5.     Dim sqlcommand As SqlCommand
  6.     Dim sqlEmployeeAdapter As SqlDataAdapter
  7.     Dim sqlEmployeeDataTable As DataTable
  8.     Dim sqlManager as CurrencyManager
  9.  
  10.  sqlcommand = New SqlCommand("SELECT * FROM [table],sqlConnection)
  11.         sqlEmployeeAdapter = New SqlDataAdapter(sqlcommand)
  12.         sqlEmployeeDataTable = New DataTable
  13.         sqlEmployeeAdapter.Fill(sqlEmployeeDataTable)
  14.         ' Fill Table with EmployeeDetails
  15. txtEmployeeCode.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeID", True)
  16.         txtSurname.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeSurname", True)
  17.         txtInitials.DataBindings.Add("Text", sqlEmployeeDataTable, "EmployeeInitials", True)
  18.         txtFirstNames.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeFirstName", True)
  19.         cbTitle.DataBindings.Add("SelectedItem", sqlEmployeeDataTable, "EmployeeTitle", True)
  20.         txtNickName.DataBindings.Add("text", sqlEmployeeDataTable, "EmployeeNickName", True)
  21.  
  22. sqlEmployeeManager = DirectCast(Me.BindingContext(sqlEmployeeDataTable), CurrencyManager)
like dat
Jul 7 '08 #2
Thanks for your quick response. I am leaving fior teh airport in an hour, so will look at it on my return

Many thanks
Jul 7 '08 #3
I have looked at your response and am unable to work through it. I am not sure that it answers my question.

All I want to know is what the syntax is for making a field in a dataset = a value.

i.e.

I have a dataset call employeesdataset
within the dataset is a table called employees
within the table is a field called hotel

I want to set the value of this field (within the current record the form is creating) to 41

the other fields within the current record are bound to the form are are inputted by the user.

The hotel field is not a field on the form but is held within the record.

How to I make the field Hotel=41 before saving the record

Hope this helps
Jul 23 '08 #4

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

Similar topics

6
by: ma | last post by:
Hello, Some questions about upgrading to MSVC 2008. 1- I am using MSVC2005, Do you recommend that I upgrade to MSVC 2008 Beta 2? 2- When the MSVC2008 will be officially release? 3- Where...
4
by: bj7lewis | last post by:
I am currently C++/Win32/MFC & C# programmer using VS.NET 2002 and jumped into VS.NET 2003 but that was a waste so I skipped VS.NET 2005 cause buying VS.NET 2003. Now after checking out VS.NET 2008...
7
by: Cirene | last post by:
I installed the RTM version of Visual Studio 2008 today. Initially when I would open any of my 2005 projects (.NET 2.0) it would simply open them. Now the Visual Studio Conversion Wizard is...
0
by: =?Utf-8?B?TWlyYW5v?= | last post by:
I tried it several times, setup disk is not damaged, everything is fine, but it always fails with the error below after completing like 75% of the installation. Then I saw other posts, and figured...
7
by: sandal | last post by:
When will I be able to buy the upgrade from vs 2003 pro to vs 2008 pro? I don't have an msdn subscription. Also I was going to use the trial version of vs 2008 in the interim but vs 2008 pro...
0
by: David Goodger | last post by:
I am pleased to announce that PyCon 2008 registration is now open! http://us.pycon.org/2008/registration/ Early-bird registration is open until February 20, so there's one month to register at...
0
by: Fortis Florin | last post by:
CALL FOR PAPERS: Workshop on Workflow and Process Management (WfPM'08), September 2008, Timisoara, Romania ...
0
by: John | last post by:
Hi An outlook 2003 add-in solution created in vs 2008 on a pc with outlook 2007 when re-opened in vs 2008 brings up the conversion wizard. Cancelling wizard closes solution and does not allow to...
0
by: Fortis Florin | last post by:
2nd CFP: Workshop on Workflow and Process Management (WfPM'08), September 2008, Timisoara, Romania EXTENDED DEADLINES...
0
by: Fortis Florin | last post by:
Final CFP: Workshop on Workflow and Process Management (WfPM'08), September 2008, Timisoara, Romania EXTENDED DEADLINES ___________________________________________________________________________­...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.