Board index » delphi » Could not convert variant of type (null) into type (String)

Could not convert variant of type (null) into type (String)

When connecting to an Access 2000 database through Delphi 7 Pro's ADO
components (ADOTable and ADOConnection), I get the following error.  Any
ideas of how to resolve this?

Error Message:
Could not convert variant of type (null) into type (String)

 

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


You need to use Vartostr(...)
Quote
"Greg Bishop" <gvbis...@earthlink.net> wrote in message

news:3e43ef22$2@newsgroups.borland.com...
Quote
> When connecting to an Access 2000 database through Delphi 7 Pro's ADO
> components (ADOTable and ADOConnection), I get the following error.  Any
> ideas of how to resolve this?

> Error Message:
> Could not convert variant of type (null) into type (String)

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


So, if I'm using all bound controls, how/where do I implement VarToStr(...)?

Thanks.

Quote
"NewsGroups.borland.com" <j...@3log.com> wrote in message

news:3e444b6d$1@newsgroups.borland.com...
Quote
> You need to use Vartostr(...)
> "Greg Bishop" <gvbis...@earthlink.net> wrote in message
> news:3e43ef22$2@newsgroups.borland.com...
> > When connecting to an Access 2000 database through Delphi 7 Pro's ADO
> > components (ADOTable and ADOConnection), I get the following error.  Any
> > ideas of how to resolve this?

> > Error Message:
> > Could not convert variant of type (null) into type (String)

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


Quote
>When connecting to an Access 2000 database through Delphi 7 Pro's ADO
>components (ADOTable and ADOConnection), I get the following error.  Any
>ideas of how to resolve this?

This is a problem using the ODBC driver.  Why would you want to do that instead
of using the Jet Oledb driver?
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

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


I assume that is as simple as changing the Provider property value to:
Microsoft.Jet.OLEDB.4.0.  But, when doing so, I now get the error message,
"Read-only property value was not set."

Any thoughts?

"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:80jb4vsrag12f4f4rfpp4iuiplq5420b3p@4ax.com...

Quote

> >When connecting to an Access 2000 database through Delphi 7 Pro's ADO
> >components (ADOTable and ADOConnection), I get the following error.  Any
> >ideas of how to resolve this?
> This is a problem using the ODBC driver.  Why would you want to do that
instead
> of using the Jet Oledb driver?
> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

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


Quote
>I assume that is as simple as changing the Provider property value to:
>Microsoft.Jet.OLEDB.4.0.

No.  Other parts of the connection string are relevant to the Provider.  You
should use the connection Wizard and create a new connection string
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

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


I take the easy way and test if the field is null before converting.

uses variants;

 if q_test['field'] <>  null then
   begin
   end;

Sometimes I use
  try
    s := q_test['field'];
  except
    s := '';
  end;

Seems to work OK.
--

Dr Barry Clark
Senior Lecturer & IT Systems Designer
Medical Education Unit
Wolfson Medical Building
University of Glasgow
Glasgow G12 8QQ
Tel: 0141-330-4248
Email: b.cl...@clinmed.gla.ac.uk
"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:94sg4v08gack2ki0snrb3kflmau5m1rvdd@4ax.com...

Quote
> >I assume that is as simple as changing the Provider property value to:
> >Microsoft.Jet.OLEDB.4.0.
> No.  Other parts of the connection string are relevant to the Provider.
You
> should use the connection Wizard and create a new connection string
> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Other Threads