Discussion:
Inserting into table with MEMO field
(too old to reply)
SQLScott
2004-12-06 15:53:06 UTC
Permalink
Good morning,

I am using a VB.Net application to read/write from a Foxpro database. Let
me say out front that I am not a Foxpro guru by any stretch of the
imagination so your help would be greatly appreciated.

I am trying to insert a record (via my VB.Net app) into a Foxpro table that
has a MEMO field. I am getting the error "Data Type Mismatch" back. I have
tested every other column to make sure it is not one of the others that is
throwing the error.

I tried passing an empty string to the memo field, didn't work. I tried
excluding the MEMO field from my Insert statement but that didn't work
either. I don't know if setting the column as "NULL" will solve the problem,
but it also may NOT be an option.

Can someone explain to me how memo fields work and what I can do be able to
insert records into this table?

Thoughts? TIA...
--
Thanks,

Scott
Eric den Doop
2004-12-06 18:37:02 UTC
Permalink
Can you post your SQL command?
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
SQLScott
2004-12-06 18:53:03 UTC
Permalink
Thanks for the response Eric. After all that fighting with it, it was
pointed out to me that when inserting into a table with date columns (which
this table has), the date values need to be inclosed in { }. So, it wasn't
the memo field after all. I did find out that I still need to include it in
the insert statement, but passing it an empty string was good enough.

Dang foxpro sql... <grin>

Scott
Post by Eric den Doop
Can you post your SQL command?
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Cindy Winegarden
2004-12-07 16:08:41 UTC
Permalink
Hi Scott,

Just so you'll know, here's some code I posted earlier where the question
was about a long character string and a memo field. The trick was to use a
parameterized statement:
Imports System.Data.OleDb
Module Module1
Sub Main()

' Assumes VFP table TestADO (Id C(10), Memo1 M)
' in database Test.dbc

Dim OleDbConnection1 = New OleDbConnection("User ID=;DSN=;" & _
"Cache Authentication=False;Data Source=""C:\MY DOCUMENTS\VISUAL FOXPRO
PROJECTS\TEST.DBC"";" & _
"Password=;Provider=""VFPOLEDB.1"";Collating Sequence=MACHINE;Mask
Password=False;Mode=Share Deny None;" & _
"Extended Properties=;Encrypt Password=False")

OleDbConnection1.Open()


Dim OleDbCommand1 As OleDbCommand = New OleDbCommand
OleDbCommand1.Connection = OleDbConnection1
OleDbCommand1.CommandType = CommandType.Text
OleDbCommand1.CommandText = _
"INSERT INTO TestADO (Id, Memo1) VALUES (?, ?)"

Dim Parm0 As OleDbParameter = New Data.OleDb.OleDbParameter
Dim Parm1 As OleDbParameter = New Data.OleDb.OleDbParameter
OleDbCommand1.Parameters.Add(Parm0)
OleDbCommand1.Parameters.Add(Parm1)

OleDbCommand1.Parameters(0).Value = "Id Here"

OleDbCommand1.Parameters(1).Value = _
"The quick brown fox jumped over the lazy dog. 50" & _
"The quick brown fox jumped over the lazy dog. 100" & _
"The quick brown fox jumped over the lazy dog. 150" & _
"The quick brown fox jumped over the lazy dog. 200" & _
"The quick brown fox jumped over the lazy dog. 250" & _
"The quick brown fox jumped over the lazy dog. 300" & _
"The quick brown fox jumped over the lazy dog. 350" & _
"The quick brown fox jumped over the lazy dog. 400" & _
"The quick brown fox jumped over the lazy dog. 450" & _
"The quick brown fox jumped over the lazy dog. 500"

Dim RowsAffected As Integer = OleDbCommand1.ExecuteNonQuery()
OleDbConnection1.Close()
End Sub
End Module
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
Post by SQLScott
I am trying to insert a record (via my VB.Net app) into a Foxpro table that
has a MEMO field.
Loading...