|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to get the memo field from *.fpt file of foxpro database?I have connected to the foxpro free file a.dbf with odbcconnection,and
I can read data from common field,but how to get the memo field value from *.fpt file? DataRow dr = ds.Tables[0].Rows[i]; StringBuilder strb = new StringBuilder(); strb.Append("<rec>\r\n"); strb.Append("<title>=").Append(dr["title"]).Append("\r\n"); strb.Append("<department>=").Append(dr["department"]).Append("\r\n"); strb.Append("<content>=").Append(dr["content"]).Append("\r\n"); ........................ the "content" field is memo field..... Hi Szasam,
First, be sure you've got the latest FoxPro and Visual FoxPro ODBC drivers, downloadable from msdn.microsoft.com/vfoxpro/downloads/updates. You may be better off using the OLE DB data provider (downloadable from the same page) as it's more recent and handles some things that ODBC doesn't. You might try OLE DB and see how it goes. When you access FoxPro files the data engine takes care of accessing the Memo field for you. You don't access the FPT file directly, only the DBF file. If you opened the table natively you'd see "Memo" in the Memo field but if you double-clicked it you'd get an edit window with the text of the Memo. Some Memo fields may not have any content. What happens on the last line of your code? Do you get an error? The following VB code works for me: Dim cn As New OleDbConnection( _ "Provider=VFPOLEDB.1;Data Source=C:\Temp\;") cn.Open() Dim cmd1 As New OleDbCommand("Create Table FoxMemo (Field1 I, Field2 M)", cn) Dim cmd2 As New OleDbCommand("Insert Into FoxMemo Values (1, " + _ "'The quick brown fox jumped over the lazy dog')", cn) cmd1.ExecuteNonQuery() cmd2.ExecuteNonQuery() Dim da As New OleDbDataAdapter( _ "Select * From FoxMemo", cn) Dim ds As New DataSet() da.Fill(ds) '-- See what we've got MsgBox(ds.Tables(0).Rows(0).Item(0).ToString() + _ ", " + ds.Tables(0).Rows(0).Item(1).ToString()) Dim dr As DataRow = ds.Tables(0).Rows(0) Dim strb As New System.Text.StringBuilder() strb.Append("Field1: ") _ .Append(ds.Tables(0).Rows(0).Item("Field1").ToString()) _ .Append(Microsoft.VisualBasic.Constants.vbCrLf) strb.Append("Field2: ") _ .Append(ds.Tables(0).Rows(0).Item("Field2").ToString()) _ .Append(Microsoft.VisualBasic.Constants.vbCrLf) MsgBox(strb.ToString()) -- Show quoteCindy Winegarden MCSD, Microsoft Visual FoxPro MVP cindy_winegar***@msn.com www.cindywinegarden.com "szasam001" <szasam***@hotmail.com> wrote in message news:1141110508.773552.196240@t39g2000cwt.googlegroups.com... >I have connected to the foxpro free file a.dbf with odbcconnection,and > I can read data from common field,but how to get the memo field value > from *.fpt file? > > DataRow dr = ds.Tables[0].Rows[i]; > StringBuilder strb = new StringBuilder(); > strb.Append("<rec>\r\n"); > strb.Append("<title>=").Append(dr["title"]).Append("\r\n"); > strb.Append("<department>=").Append(dr["department"]).Append("\r\n"); > strb.Append("<content>=").Append(dr["content"]).Append("\r\n"); > ....................... > > the "content" field is memo field..... > |
|||||||||||||||||||||||