473,405 Members | 2,279 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,405 software developers and data experts.

How to convert a text value to an integer and store this in a table using VB.NET

Hi,

I have created an AssetTracking database in SQL Server 2000 and one of my
master tables generates an autonumber for a unique PC Make. For example my
table will consist of the following:

1 HP
2 Dell
3 Fujitsu

My main table which will holds the PC Information includes a PCMakeID field
to represent the PC Make.
In VB.NET, I have added a DBCombo to populate the PC Make details. When I
press the Save button on the form to save the details to the PC Information
table, I want to save the PCMakeID value into the table instead of the
actual text value.

Does anyone know how to go about achieving this task.

Regards

Dipendra

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #1
3 1411
Can't you just use: 'CInt(TextBox1.Text)' for example?

"Dipendra Darbar via DotNetMonster.com" wrote:
Hi,

I have created an AssetTracking database in SQL Server 2000 and one of my
master tables generates an autonumber for a unique PC Make. For example my
table will consist of the following:

1 HP
2 Dell
3 Fujitsu

My main table which will holds the PC Information includes a PCMakeID field
to represent the PC Make.
In VB.NET, I have added a DBCombo to populate the PC Make details. When I
press the Save button on the form to save the details to the PC Information
table, I want to save the PCMakeID value into the table instead of the
actual text value.

Does anyone know how to go about achieving this task.

Regards

Dipendra

--
Message posted via http://www.dotnetmonster.com

Nov 21 '05 #2
"Dipendra Darbar via DotNetMonster.com" <fo***@DotNetMonster.com> schrieb:
I have created an AssetTracking database in SQL Server 2000 and one of my
master tables generates an autonumber for a unique PC Make. For example my
table will consist of the following:

1 HP
2 Dell
3 Fujitsu

My main table which will holds the PC Information includes a PCMakeID
field
to represent the PC Make.
In VB.NET, I have added a DBCombo to populate the PC Make details. When I
press the Save button on the form to save the details to the PC
Information
table, I want to save the PCMakeID value into the table instead of the
actual text value.


For a culture-sensitive conversion use 'CInt', for a converstion with
invariant culture semantics use 'Val'. Alternatively you can use
'Integer.Parse' and pass an appropriate 'CultureInfo' object to this method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
Dipendra,

When you use an datatable to load your object (from your database or build
by hand) than you can use the displaymember for your text and the
valuemember for your id.

When you need it you use the selectedvalue.

I hope this helps,

Cor
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Learner | last post by:
Hello, I am trying to store the data entered in a webform in the database. I have few Int and one SmallDateTime filed in my table in SQL Server 2005 database. I have made a storedproc to store the...
3
by: mrajanikrishna | last post by:
Hi Friends, I am accepting a number from the user entered in a textbox. I want to assign to a variable in my code and assignt this to that variable. double num1 = (double)txtNum1.text; ...
5
by: Elainie | last post by:
I would like to convert data numbers to text.... i.e. 1 = Inactive 2 = Due 3 = Received 4 = Problems 5 = Cleared Their is numbers in the fields at the moment but they need to be converted to...
10
by: cmdolcet69 | last post by:
Public ArrList As New ArrayList Public bitvalue As Byte() Public Sub addvalues() Dim index As Integer ArrList.Add(100) ArrList.Add(200) ArrList.Add(300) ArrList.Add(400) ArrList.Add(500)
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.