Re: CHANGING DATA TYPE



"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

.



Relevant Pages

  • Re: A little Rolodex [revised]
    ... including alpha sort and searching for any embedded string, ... In this application, a database is a directory, ... you may optionally provide any alternate UCASE program, ... NN -> first store NN as key length ...
    (comp.sys.hp48)
  • Re: return multiple rows from sql statement
    ... strings from input values is almost certainly a safe path to SQL ... Also, being a MySQL function, it knows what MySQL needs or uses. ... All characters that are entered in the fields make their way into the database unaltered. ... The insert of what surprisinlgly was NOT a syntax error, but a string called "mysql_insert_id" into an integer field resulted in the value zero being put in. ...
    (comp.lang.php)
  • Re: Code to delete/unlink Linked tables
    ... Public intLinkODBCTables As Variant, intLinkDB2Tables As Variant ... Public strLinkBackendDB As String, strLinkDSNname As String, strLinkLibName ... ' MsgBox "This database is in MDE format...I will delete/recreate ODBC ... Public Sub fncLinkDB2Table() ...
    (microsoft.public.access.modulesdaovba)
  • Re: Establish connection with and transferring data to Access
    ... The specific problem with your code is that you need to quote string ... Dim vConnection As New ADODB.Connection ... Experiment with the object model or check the documentation for the ... Doug's code opens and writes to an existing database. ...
    (microsoft.public.word.vba.general)
  • Re: Invalid variant type conversion
    ... because within regular programming, there would be no agreement upon what ... applications built by standard Delphi controls, ... NULL is the same as "" in a database. ... >> The empty string tells it all. ...
    (comp.lang.pascal.delphi.misc)