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

CHANGING DATA TYPE

Dim ProductPropertyValues_Value as string

ProductPropertyValues_Value = xx("ProductPropertyValues_Value")

it returns error.. Because xx("ProductPropertyValues_Value") returns NULL
or "" records?

How can i convert it to string or which method should i use it ?
Jan 20 '06 #1
9 1199
"Savas Ates" <in da club> schrieb
Dim ProductPropertyValues_Value as string

ProductPropertyValues_Value = xx("ProductPropertyValues_Value")

it returns error.. Because xx("ProductPropertyValues_Value")
returns NULL or "" records?

How can i convert it to string or which method should i use it ?

Did you enable Option Strict?

What is xx("ProductPropertyValues_Value")?

What is the type of xx("ProductPropertyValues_Value")?

What is the instance type of the object returned by
xx("ProductPropertyValues_Value")?
Armin

Jan 20 '06 #2
Dim xx As SqlClient.SqlDataReader

I take values from my db by appliying that method. ?

"Armin Zingler" <az*******@freenet.de>, haber iletisinde þunlarý
yazdý:e%****************@TK2MSFTNGP15.phx.gbl...
"Savas Ates" <in da club> schrieb
Dim ProductPropertyValues_Value as string

ProductPropertyValues_Value = xx("ProductPropertyValues_Value")

it returns error.. Because xx("ProductPropertyValues_Value")
returns NULL or "" records?

How can i convert it to string or which method should i use it ?

Did you enable Option Strict?

What is xx("ProductPropertyValues_Value")?

What is the type of xx("ProductPropertyValues_Value")?

What is the instance type of the object returned by
xx("ProductPropertyValues_Value")?
Armin

Jan 20 '06 #3
"Savas Ates" <in da club> schrieb
Dim xx As SqlClient.SqlDataReader

I take values from my db by appliying that method. ?

How do you intend to handle Null values coming from the database? You can
not store them in a string. Declare the variable As Object.

dim ProductPropertyValues_Value as object

ProductPropertyValues = xx("ProductPropertyValues_Value")

Later, if you want to distinguish between Null and String, you have to
write:
if ProductPropertyValues_Value is dbnull.value then
'handle null value
else
'handle string
end if

- OR -

Some people convert DBNull to Nothing in order to be able to declare the
variable As String:

Dim ProductPropertyValues_Value as string
dim o as object

o = xx("ProductPropertyValues_Value")

if o is dbnull.value then
ProductPropertyValues_Value = Nothing
else
ProductPropertyValues_Value = o.ToString
end if

Later usage:
if ProductPropertyValues_Value is nothing then
'...
else
'...
end if

Later, if you want to save the values back to the database, you have to
convert back from Nothing to DBNull.Value.
Typed datasets, or classes that you create on your own, can have typed
members (As String) that simplifies this (because the member is typed), and
they have additional "IsMemberNull" and "SetMemberNull" methods.
Armin

Jan 20 '06 #4
"Savas Ates" <in da club> schrieb:
Dim ProductPropertyValues_Value as string

ProductPropertyValues_Value = xx("ProductPropertyValues_Value")

it returns error.. Because xx("ProductPropertyValues_Value") returns NULL
or "" records?

How can i convert it to string or which method should i use it ?


\\\
Dim Value As Object = xx("...")

' 'If Value Is DBNull.Value Then...'.
If IsDBNull(Value) Then
s = ""
Else
s = DirectCast(Value, String)
End If
///

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

Jan 20 '06 #5
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schrieb
Dim Value As Object = xx("...")

' 'If Value Is DBNull.Value Then...'.
If IsDBNull(Value) Then
s = ""


This means, you can not distinguish between Null and "" anymore, later. I
guess this is not intended because if both were equal, the database design
would be wrong (usually).
Armin

Jan 20 '06 #6
"Armin Zingler" <az*******@freenet.de> schrieb:
Dim Value As Object = xx("...")

' 'If Value Is DBNull.Value Then...'.
If IsDBNull(Value) Then
s = ""


This means, you can not distinguish between Null and "" anymore, later. I
guess this is not intended because if both were equal, the database design
would be wrong (usually).


This depends on what you want to archive. If the intention is to display
the values in labels or similar, then my code makes sense, IMO.

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

Jan 20 '06 #7
Armin,

Do I see something wrong

ToString or Cstr does mostly everything in these cases.

However because all these answers I become confused.

Cor
Jan 20 '06 #8
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schrieb
"Armin Zingler" <az*******@freenet.de> schrieb:
Dim Value As Object = xx("...")

' 'If Value Is DBNull.Value Then...'.
If IsDBNull(Value) Then
s = ""


This means, you can not distinguish between Null and "" anymore,
later. I guess this is not intended because if both were equal,
the database design would be wrong (usually).


This depends on what you want to archive. If the intention is to
display the values in labels or similar, then my code makes sense,
IMO.

As from the OP's post I only see a String typed variable, I can not assume
that a label will be used. I can only answer based on the information I
have. That's why I also assume the correct database design. Consequently, it
does not make sense to convert Null to "". But let's wait for the OP's
answer.
Armin

Jan 20 '06 #9
"Cor Ligthert [MVP]" <no************@planet.nl> schrieb
Armin,

Do I see something wrong

ToString or Cstr does mostly everything in these cases.

However because all these answers I become confused.

Cor

DBNull.Tostring probably gives not the result expected.
Armin
Jan 20 '06 #10

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

Similar topics

1
by: Robert V | last post by:
Hi all, another area I could use some help with is changing submitted data based on the data conditions ... I will elaborate. I have a form textarea where a user can type in some text. This text is...
5
by: Eternally | last post by:
Hey folks, To me, this sounds like a crazy question, but I'll throw it out there anyway. Is it possible to change a variables data type half way through a running program? If so, how? ...
1
by: iporter | last post by:
Hi - I am changing a field from type nvarchar to type text, given that I need to store strings longer than 255 characters. To do this I change the data type in SQL Server, then I change the...
7
by: Stefan Finzel | last post by:
Hi, is there a way to change the display property on Windows Mobile 2003 SE Mobile/Pocket Internet Explorer? See following example. Please note: visibilty property has the same problem. Is...
13
by: Peter | last post by:
Can anyone tell me how to change the data type of a field in a table created with a make table query? The field is a binary and must be changed to text. alternately does anyone know how to specify...
2
by: S P Arif Sahari Wibowo | last post by:
Hi! Do you know how to put a form's Access-Visual-Basic-code that will force the form to be inserted, while the user has not type anything in the form, without changing focus, selection, etc.? ...
4
by: andychambers2002 | last post by:
I'm working on a "TempFile" class that stores the data in memory until it gets larger than a specified threshold (as per PEP 42). Whilst trying to implement it, I've come across some strange...
1
by: Blasting Cap | last post by:
I am having trouble changing the font for a PushButton control in a datagrid button column. I have seen several posts refer to styles and simple changes to the HTML for font changes but most of...
4
by: laxmikiran.bachu | last post by:
Can we have change a unicode string Type object to a Tuple type object.. If so how ????
5
by: veer | last post by:
hello expert can any one help me by providing the method how can i change the data type of column in sql server originally my column data type is numeric and i want to change it into integer i...
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.