Hello Peter,
My name is Trevor Hancock. I am a member of the Visual FoxPro support team
and I will try to help here.
Fox itself has no method to store an empty value to a GENERAL field. There
are only two ways to populate that type of field in Fox:
(1) The APPEND GENERAL command.
(2) Using the VFP IDE, specifically the Edit>Insert Object menu option.
There is no way to insert a value into the general field with an UPDATE or
INSERT command. For instance, let's say we have a table named TST with two
fields:
IID Int
MYGEN General
This command will produce a data type mismatch error inside VFP:
INSERT INTO TST VALUES (1,"")
As I said, past the IDE and the APPEND GENERAL command, there is no way to
populate that GENERAL field.
However, I have found something interesting with the VFP OLE DB Provider
and .NET. The following code allows me to insert a new record into the
aforementioned table:
Dim oConn As New OleDbConnection ("Provider=VFPO LEDB;Data
Source=D:\dotne ttst")
Dim oCmd As New OleDbCommand()
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandTyp e = CommandType.Tex t
oCmd.CommandTex t = "Insert Into TST Values (4000,[])"
oCmd.ExecuteNon Query()
oConn.Close()
oConn.Dispose()
oCmd.Dispose()
What is odd to me about this is the fact that this very same INSERT
command, when run inside VFP will error out. However, through the provider
it works fine!
I am in discussions with my product group over this, but in the meantime
this may help you get around your problem.
Respectfully,
Trevor Hancock, MCSD
Microsoft Developer Support - FoxPro
*-- VFP8 HAS ARRIVED!! --*
Read about all the new features of VFP8 here:
http://www.universalthread.com/Visua...FP8Release.asp
Purchase VFP8 here:
http://shop.microsoft.com/Referral/P...p?siteID=11518
Keep an eye on the product lifecycle for Visual FoxPro here:
http://support.microsoft.com/default.aspx?id=fh;[ln];lifeprodv
- VFP5 Mainstream Support retires June 30th, 2003
- VFP6 Mainstream Support retires Sep. 30th, 2003
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
*--Content-Class: urn:content-classes:message
*--From: <pe***@chsoft.c om>
*--Sender: <pe***@chsoft.c om>
*--Subject: Invalid cast from system.byte to system.byte[]
*--Date: Fri, 1 Aug 2003 11:08:06 -0700
*--Lines: 36
*--Message-ID: <02************ *************** *@phx.gbl>
*--MIME-Version: 1.0
*--Content-Type: text/plain;
*-- charset="iso-8859-1"
*--Content-Transfer-Encoding: 7bit
*--X-Newsreader: Microsoft CDO for Windows 2000
*--Thread-Index: AcNYV9tYzVT7zyX rRfCHya3yr3WHJQ ==
*--X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
*--Newsgroups: microsoft.publi c.dotnet.genera l
*--Path: cpmsftngxa06.ph x.gbl
*--Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.genera l:103149
*--NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
*--X-Tomcat-NG: microsoft.publi c.dotnet.genera l
*--
*--When I execute the following (with an OleDBDataAdapte r),
*--wanting to add a row to a visual foxpro table:
*--
*-- myrow= datasetTarget.T ables(0).NewRow
*-- 'fill all columns here like..
*-- row(i)= myvalue
*-- ' then
*-- datasetTarget.T ables(0).Rows.A dd(myrow)
*-- dataAdapterTarg et.Update(datas etTarget.Tables (0)) '*
*--
*-- I get "Invalid cast from system.byte to system.byte[]"
*--exception.messa ge executing the * marked line, when I use
*--row(i)=cbyte(1) .
*-- I get the message "ColumnName does not accept null values"
*--when I use row(i)=b ', where dim b as system.byte =
*--{12,13,14}
*-- Assigning other data types like integer, double, even with
*--cbyte(..) gives similar errors.
*--
*-- The failing column is from a Visual Foxpro table (to which
*-- I connected via an OledbDataAdapte r, using vfpoledb.dll
*--ver 8.0.0.2521).
*--The trouble column is not nullable. Its VFP data type is
*--'General', as shown by the VFP ver 6 IDE Table Designer.
*--I cannot change the type of the column (it's not my table).
*--So what do I assign to row(i) in this case if I want to
*--leave it empty
*--
*--(in case of a string type I would assign row(i)="").
*--This column is supposed to store bit images from icons, but
*-- I need to fill this column with nothing, not having any
*--icon bitmaps.
*--This problem appears only when the VFP datatype is
*--'General'; otherwise my column filling algorithm works.
*--TIA
*--
*--