vc 获取数据库数据问题

wssd89 2012-07-18 03:29:42
vc 程序 获取数据库表中的text类型数据 在程序的文本控件中显示的数据并不完整

text数据类型 应该如何操作 跪 求解————————
...全文
157 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
中年風雨 2012-07-22
  • 打赏
  • 举报
回复
晕菜!兄弟,CListCtr控件是有长度限制的,除非你自己重载一个。


//MListCtrl.h
#if !defined(AFX_MLISTCTRL_H__9D014815_8777_4347_B97A_41D2763EAB79__INCLUDED_)
#define AFX_MLISTCTRL_H__9D014815_8777_4347_B97A_41D2763EAB79__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CMListCtrl : public CListCtrl {
public:
CMListCtrl();
virtual ~CMListCtrl();
public:
BOOL SetItemText(int nItem, int nSubItem, LPCTSTR lpszText);
CString GetItemText(int nItem, int nSubItem);
};

#endif // !defined(AFX_MLISTCTRL_H__9D014815_8777_4347_B97A_41D2763EAB79__INCLUDED_)




#include "stdafx.h"
#include "MListCtrl.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMListCtrl::CMListCtrl() {
CListCtrl::CListCtrl();
}

CMListCtrl::~CMListCtrl() {
CListCtrl::~CListCtrl();
}

BOOL CMListCtrl::SetItemText(int nItem, int nSubItem, LPCTSTR lpszText) {
ASSERT(::IsWindow(m_hWnd));
ASSERT((GetStyle() & LVS_OWNERDATA)==0);
LVITEM lvi;
lvi.iSubItem = nSubItem;
lvi.pszText = (LPTSTR)lpszText;
::SendMessage(m_hWnd, LVM_SETITEMTEXT, nItem, (LPARAM)&lvi);
return (BOOL) ::SendMessage(m_hWnd, LVM_SETITEMTEXT, nItem, (LPARAM)&lvi);
}

CString CMListCtrl::GetItemText(int nItem, int nSubItem) {
ASSERT(::IsWindow(m_hWnd));
LVITEM lvi;
memset(&lvi, 0, sizeof(LVITEM));
lvi.iSubItem = nSubItem;
CString str;
int nLen = 1024; //修改此值,以改变Item长度限制
int nRes;
do {
nLen *=2;
lvi.cchTextMax = nLen;
lvi.pszText = str.GetBufferSetLength(nLen);
nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi);
} while (nRes == nLen-1);
str.ReleaseBuffer();
return str;
}



下次找错误,一定要想清楚问题所在。

wssd89 2012-07-20
  • 打赏
  • 举报
回复
是sql 数据库

重新说下问题 :

在列表控件中 显示数据库中的text类型数据 在向list控件填充数据之前 用Messagebox显示从数据库获取的数据是正确的 但是(m_list.SetItemText(row,index+1,text);) 填充数据后 控件中显示的数据不完整 而且回车,换行 变成了||
m_list.GetItemText(nItem,12) 获取的数据也是不完整的了 ------
wssd89 2012-07-19
  • 打赏
  • 举报
回复
"This page has three sections that need to be researched differently.
A) For Leads posted in the ""Projects out for Bid"" section - do the following
1. NOTE: You will need to drill into each posted lead to check for amendments
2. Click on the Project Name to access a details page
3. Click on the “Online Plans and Specifications link”
4. Click “I Agree”
5. If amendments are listed, do the following
6. Choose amendment as event type
7. Capture amendment date and number and paste to description
8. Return to the details page from step 2
9. Capture Bid title (bold at top of page) and Submission deadline, and paste to description
10. If no amendments are posted and/or lead is new, do the following
11. Choose Bid as event type
12. follow steps 8 & 9
13. Click on the “Advertisement” link and attach doc
NOTE: Add the following text to the end of the description for all leads: “Documents can be ordered online or by contacting DocuCopy, LLC, 3334 Brown Station Road, Columbia, Missouri 65202, Ph: (573) 814-1700, Fax: (573) 814-1725”

B) For leads posted in “Projects in Design” - do the following
1. Choose Advanced Notice as event type
2.. Capture table headers and paste to description
3. Capture lead line information and paste to description next to their appropriate headers

C) For leads posted in the “Projects that Recently Bid” section - do the following
1) Choose award as event type
2) Capture table headers and paste to description
3) Capture lead line information and paste to description next to their appropriate headers"


比如以上数据 只获取了
"This page has three sections that need to be researched differently.
A) For Leads posted in the ""Projects out for Bid"" section - do the following
1. NOTE: You will need to drill into each posted lead to check for amendments
2. Click on the Project Name to access a details page
中年風雨 2012-07-19
  • 打赏
  • 举报
回复
是access数据库?
access数据库text字段只能存255字符。

我写的测试程序:
http://download.csdn.net/detail/pardream/4438281
ouyh12345 2012-07-18
  • 打赏
  • 举报
回复
怎么个不完整法?读到什么,显示又是什么?

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧