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

  • Thread starter Thread starter Dipendra Darbar via DotNetMonster.com
  • Start date Start date
D

Dipendra Darbar via DotNetMonster.com

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
 
Dipendra Darbar via DotNetMonster.com said:
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top