Re: Could not convert variant of type (Null) into type (String)



My English is pretty bad too... being American!! (tee hee)

I've seen this error SO many times... trying to pin down exactly where I've
seen it is turning out to be the difficulty...

I think that it all stemmed from my misperception that '' and <NULL> were
the same thing... they are NOT NOT NOT... (that lesson caused me a lot of
pain)

check these points:
-If you are setting a field in you SQL database which is requiring a string
be sure that you are in fact giving it a string and not a NULL/NIL value
-If you are feeding it an empty string '' where you intend for it to be
<NULL> the best way I've found is to us adotbl.fieldreference.CLEAR; (just
found it, love it)
-If you are are using a query with a where clause and trying to find a ''
(blank) value by using where field='' use where field IS NULL instead...
(but then be sure and use CLEAR (above) so you aren't missing some intended
records in your result set... although I don't think this would cause your
error it is along the same thought process of null vs ''

Working through these issues I found it useful to watch the database
directly while testing the application to watch for individual results to
changes and insertions just to make certain that I was getting the result
that I was expecting.

Hope that helps.

b
"zorba" <tjall@xxxxxxxxxxxx> wrote in message
news:421e3217@xxxxxxxxxxxxxxxxxxxxxxxxx
> I connect with SQL Server(MSDE) database using ADO(Microsoft OLE DB
> Provider for ODBC Drivers).Durnig compilation occured exception "Could
> not convert variant of type (Null) into type (String)". What's causing
> that problem?
>
> Sorry for my English :)
>
>
>
> --- posted by geoForum on http://delphi.newswhat.com


.



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)