 |
|
 |
Hello! I get Assertion Failed on line 146 in DBFTableDef.cpp
My code is:
CDBFTableDef t;
t.CreateTable("aaaa.dbf");
FIELD_REC FieldRec;
memset(&FieldRec, 0, sizeof(FIELD_REC));
memcpy(FieldRec.field_name, "f2", 2);
FieldRec.field_type = FLD_TYPE_NUMERIC;
t.AddField(&FieldRec);
memcpy(FieldRec.field_name, "f3", 2);
FieldRec.field_type = FLD_TYPE_CHARACTER;
t.AddField(&FieldRec);
t.UpdateTable();
t.Close();
CDBFRecordset m_Set;
m_Set.Open("aaaa.dbf");
m_Set.AddNew();
COleVariant var;
var.vt = VT_I4;
var.intVal = 11;
m_Set.SetFieldValue("f1", &var);
var.vt = VT_BSTR;
var.bstrVal = L"aaaaa";
m_Set.SetFieldValue("f2", &var);
m_Set.Update();
m_Set.Close();
Can't find mistake
Please help!
|
|
|
|
 |
|
 |
Found myself.
It was FieldRec.len_info
|
|
|
|
 |
|
 |
Hi! I would like to know if there is a way to use this library without using mfc??
Thank you!
|
|
|
|
 |
|
|
 |
|
 |
Hi
Could someone tell me how I can view/retrieve a content of a single field ?
Thanks
|
|
|
|
 |
|
 |
Thanks for the excellent work.
I used it and found it a very good..
One question: I have read in the forum that when a record is deleted, it's not physically deleted, but marked with "delete flag" and, to delete it, it must be "packed". I saw that the pack() function is in the CDBFMemeCursorSet class. I used only CDBFRecordset class in my program to read and to add record; how can be used CDBFMemeCursorSet class?
Can you give me some samples on how to do it?
Thanks in advance
Paolo.
|
|
|
|
 |
|
 |
Your project solved my problem thanx alot. I want to use it under winCE platform but i have alxBASEa3.zip file (the latest) and i think indexing not supported in this source is that true ?, or how can add indexing support to my project, thanx.
|
|
|
|
 |
|
 |
I have tried the library.I did a simple Dialog based MFC project to create a new foxpro dbf file with a field called "NAME" and add new records to it.But when i run it,it is creating the database structure but while adding new record,it tells
" Debug Assertion failed"
" File: E:\alxBASE\Src\DBFRecordSet.cpp"
" Line : 450 "
void CDBFRecordset::AddNew()
{
ASSERT_VALID(this);
ASSERT(IsOpen()); "this is the line : 450 where it gets struck"
m_nEditMode = addnew;
memset(m_DBFFields.m_pCurRec, 0, m_pTableDef->m_DBFHead.rec_size);
COleVariant varEmpty;
varEmpty.Clear();
// ïðèñâàèâàåì âñåì ïîëÿì ïóñòîå çíà÷åíèå
for(short i = 0; i < m_DBFFields.GetFieldCount(); i++)
{
FIELD_REC* pFieldRec = m_DBFFields.GetFieldRec(i);
alxSetFieldValue(m_DBFFields.m_pCurRec, pFieldRec, varEmpty);
}
m_DBFFields.m_pCurRec[0] = REC_FLAG_NORMAL;
}
/* Èçìåíåíèå òåêóùåé çàïèñè */
void CDBFRecordset::Edit()
{
ASSERT_VALID(this);
ASSERT(IsOpen());
m_nEditMode = edit;
}
My program code is
#include "stdafx.h"
#include "newone.h"
#include "newoneDlg.h"
#include "DBFTableDef.h"
#include "DBFRecordset.h"
void CNewoneDlg::OnOK()
{
UpdateData();
try
{
// TODO: Add extra validation here
CDBFTableDef mNewTable;
CDBFRecordset m_Set;
char s[10];
// begin create
mNewTable.CreateTable(m_edit); //m_edit is the variable which holds the dbf file name given by the user.
// add field
FIELD_REC FieldRec;
memset(&FieldRec, 0, sizeof(FIELD_REC));
s[0]='N';s[1]='A';s[2]='M';s[3]='E';s[4]='\0';
memcpy(FieldRec.field_name,s, 20);
FieldRec.field_type = FLD_TYPE_CHARACTER;
FieldRec.len_info.char_len = 20;
mNewTable.AddField(&FieldRec);
// ...
// end create
mNewTable.UpdateTable();
m_Set.AddNew();
m_Set.Edit();
m_Set.SetFieldValue("Stephen",s);
m_Set.Update();
mNewTable.UpdateTable();
}
catch(CDBFException* e)
{
e->ReportError();
e->Delete();
}
CDialog::OnOK();
}
Please help me...Am i wrong anywhere?
Being a beginner,I m really interested in completing this small project .
Earnestly expecting your replies
V.Stephen
|
|
|
|
 |
|
 |
When you work with table structure, you use CDBFTableDef. But when you work with data itself you use CDBFRecordset. These are two different things. So, to add new records to the table, you must open it (see CDBFRecordset's Open method)
|
|
|
|
 |
|
 |
Its really a very nice project I have come across so far.Hats off to the author.But one suggestion.If an example project to create a dbf and append records into it had been included,it would have been really helpful to beginners like me.Also the settings for the project should be described in detail.
Awaiting your simple example project,
Stephen
India
|
|
|
|
 |
|
 |
Hi
Trying to use the FindFirst Function, it does not find anything, I wonder if anyone is using it succesfuly and can provide me with en example
Say I want an exact match on a column name ACCOUNT,it is a character field, with the value "ALEX" in one of te records, how should my code look to get a succesful match?
Thanks
Alex
|
|
|
|
 |
|
 |
Alex uses standard DBF syntaxis for finding records. You can simply google it for further description. As for your case, you can use this code
string condition = "ACCOUNT=="+name; // e.g "ALEX"
return table.FindFirst(condition.c_str());
|
|
|
|
 |
|
 |
OK,
Some conversion to make this UNICODE compatible, a few changes and additions - eg: CE does not have a class like CFileFind and other things.
I get my project to comile and linke with the new library but get 2 unresolved externals
LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)
error LNK2001: unresolved external symbol ___CxxLongjmpUnwind@4
Can not find anywhere what this is al bout...
Any help will be appreciated
Thanks
Alex
|
|
|
|
 |
|
 |
I am developing a WIndows CE 2003 application using eVC 4 / C++ and I tried building this library for that platform, any idea if that can work? I do not manage to build the DLL
Thanks
Alex
|
|
|
|
 |
|
 |
Hi,
I used your code, it's great!
But when i locked the record on my LAN, it's no't work. I could modified the record after it's lock by other user.
mRcset.LockRecord();
mRcset.Edit();
COleVariant newtemp;
newtemp = "123456789111";
mRcset.SetFieldValue(1,newtemp);
mRcset.Update();
mRcset.UnlockRecord();
mRcset.Close();
Could you fix my problem ?
|
|
|
|
 |
|
 |
Hi
Trying to use the FindFirst Function, it does not find anything, I wonder if anyone is using it successfully and can provide me with en example
I am using FoxPro tables, with no memo fields, no index either…
Say I want an exact match on a column name ACCOUNT, it is a character field, with the value "ALEX" in one of the records, how should my code look to get a successful match?
Thanks
Alex
|
|
|
|
 |
|
 |
Hi~
I'm use of the alxBase.
It's very useful library.
Are there some function or routine to insert/delete a image file or binary data?
Please, Help me?
|
|
|
|
 |
|
 |
Sir , I'm long time use your alx library , I'm particulay working a database project for useing your lib . But now i have problem for packed the deleted record . I used the CDBFRecordset class . please sir help me how I packed the deleted record . I also read your artical for Pack record but it's working In CDBFMemCursorset . Sir how I utilize this in CDBFRecordset class .
Waiting you help .
jassy
|
|
|
|
 |
|
|
 |
|
 |
Sir , I'm long time use your alx library , I'm particulay working a database project for useing your lib . But now i have problem for packed the deleted record . I used the CDBFRecordset class . please sir help me how I packed the deleted record . I also read your artical for Pack record but it's working In CDBFMemCursorset . Sir how I utilize this in CDBFRecordset class .
Waiting you help .
jassy
|
|
|
|
 |
|
 |
I am developing a similar project at http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=53109&lngWId=1 . I wish to find some sample db files so that I can develop it a little better. thanks in advance!
|
|
|
|
 |
|
 |
I was having problems with your classes a few days ago, so I stopped using them and opted to use ODBC functions instead to do multiple inserts. The problem was my own because I compiled a debug version of the .lib file and it was conflicting with the release version of my DLL. Now that I took care of that, everything is working great! SetFieldValue() is working about 100 times faster than using ODBC was!! But while I was using ODBC my boss asked me if I could make it also export to Excel, which was also easily done, but slow. Since I'm back using your classes now I'd like to know if you know if there's a way I can derive from your dbfrecordset class with the correct offset in the header fields to do the same thing with an .xls file? Any help would be greatly appreciated. I'm giving your article a rating of 5, by the way!
If it's broken, I probably did it
bdiamond
|
|
|
|
 |
|
 |
.xls the file has more difficult structure. The file represents OLE container in which modified structures EXCEL 4 are stored. To use dbfrecordset will fail. It is possible to use, for example: ODBC, ActiveX. Except for that in EXCEL it is possible to open dbf files of the dBASE III version.
|
|
|
|
 |
|
 |
this is my fault. I don't understand how to modify the header info correctly to specify the table type correctly (along with the other fields). I create a table, and using the sample viewer demo that came with this project, I can see the data in the table, even though a couple of the column header names are messed up. But when I try to open up the table in VFP I get a message telling me to specify the code page it was created in. I tried to modify the header info, but I can't seem to get this to work right. Can you please help?
If it's broken, I probably did it
bdiamond
|
|
|
|
 |
|
 |
The code page is define 29 byte in head of dbf file. For an example: value 0x01 - code page 437 U.S. MS-DOS, 0x03 - 1252 Windows ANSI. It is possible to determine code page through a variable m_DBFHead.code_page at creation or updating of the table (before call functions UpdateTable()). By default m_DBFHead.code_page = 0.
|
|
|
|
 |