我爱builder

C++Builder 程序员博客

比如,表名:住院信息
列名:  姓名(char)      住院时间(char)或(datetime)
      aaaa          2008-1-1
      bbbb          2008-2-2
      cccc          2008-3-3
      dddd          2008-4-4

怎样从中选出2月到4月的数据啊
我用的语句
AnsiString sql;
zQuery->SQL->Clear();
sql="select * from 住院信息 where 住院时间 between CONVERT(datetime , '";
sql+=Edit2->Text+"') and CONVERT(datetime , '" ;
sql+=Edit3->Text+"')";
zQuery->SQL->Add(sql);
zQuery->ExecSQL();
Table1->Active = true;  Edit2,3是可选的,可是选不出来,很郁闷

不是时间选不出来
是数据不能按照选定的时间段选出来

还请高人指点阿

在ExecSQL执行前增加一条把SQL写入文件的代码,
zQuery->SQL->SaveToFile("c:\\TestSQL.sql");

运行程序后打开保存的SQL文件,在查询分析器里面看看SQL有没有什么问题。

如果是DATETIME
select * from XX  where year(dt)=2008 and month(dt) between 2 and  4

如果是CHAR,如果是固定格式的如  2008-06-01
你可以用 select * from XX  where Substring(dt,1,4)='2008' and cast((Substring(dt,6,2) as int) between 2 and  4

非固定格式呵呵,要写过程了.先把日期解析出来,再把结果放到临时表中.

或者程序里面…控制,
把日期用字符,解析后得到年,月,然后把最后结果显示出来(SringGrid吧)

我也遇到过,按照时间来查询,会出错,说在将nvarchar类型转换成int类型是出错,不知道是怎么回事

  • Filed under: C++ Builder
  • 不知道大家有没有发现,在代码里写:
    // todo: 这里应该写什么代码…

    这行字就会出现在To-Do List窗口里,下次打开此工程后直接又击To-Do List窗口里的这行字就能跳到对应的代码里。
    这样我就可以在关闭BCB前把接下来的思路写到//todo:后面,然后第二天接着写了(偶第二天总是要花点时间来进入状态,有了这个进入状态的时间应该会大大减小了)。

    偶的BCB6是装了cnPack的,不知道是cnPack的功能还是BCB6自带的功能。

    俺也不知道, 俺也想试试, 俺还想拿分!

    只在2007里面发现了(复制同事的一段代码,刚好里面有//TODO:,于是后面就自己试着添加之…),CB6倒没有发现过.

    接分,cnPack是个好东西

    接分

    cnpack干嘛的

    刚看了下,CB6 也有这个功能,只是平时没注意到、也没用到,还真是挺有用!

    这个功能是 D5 就开始有的了,不过 D4 就不知道有没有,BCB3 中肯定是没有的

    呵呵 谢谢!谢谢毛。。俺还不知道呢

    少打了个毛字 呵呵。。。

    我也装了CNPACK,赶快看看

    jf不失望

    自带的,不过cnPack也蛮好用的,打了书签关闭再开还存在的。

    看起来不错/.

    引用 2 楼 sczyq 的回复:
    俺也不知道, 俺也想试试, 俺还想拿分!

    引用 14 楼 hemiya 的回复:
    引用 2 楼 sczyq 的回复:
    俺也不知道, 俺也想试试, 俺还想拿分!

    试了一下,果然(以前从不用To-Do List)
    thanks!

    试了一下,5.0的也可以

    这个本来就是BCB的功能,好像再看VC或其它代码时也看到过只是觉得它没有用,就没去管他,经你这么一说还觉得真是。

    我還以為 todo list 是用來干什麼的,原來是這樣用。真是恍然大悟啊。

    恩,接分。

    在VC中看到//TODO:注释是自动生成的,以为只是个注释(貌似没有TODO List视图),
    而在CB中发现一个To-Do List视图,却不知道怎么用(不会自动生成一个//TODO:注释)。

    谢谢毛毛的说明,多学了一招!

    在BCB6的帮助里找到说明了:
    To embed to-do list items in the source code:

    You can add specific items directly within the source code in two ways:

    Right-click in the Code editor and choose Add To-Do Item. Type the item in the Add To-Do List Item dialog box.
    Type the item in the source code using the to-do item syntax.

    To-do list items added directly into the source code relate to that specific unit module. You can add global to-do list items by right-clicking on the list and choosing Add.

    To-Do Item syntax

    Use the following syntax for to-do list items in your source code:

    /* TODO &brvbarDONE [n] [-o <owner>] [-c <category>] : <to-do item text> */

    The word TODO is changed to DONE to mark an item as completed or checked.

    Where:

    n is a priority that can be set to a number from 1 (highest) to 5 (lowest). Setting n to 0 means assign no priority. It is optional but must be specified right after the TODO or DONE keyword.
    TODO is a keyword that indicates a to-do list item. When the item is completed, changes to DONE. Case is not important.
    DONE indicates a completed to-do item. Replaces the word TODO when you check an item in the to-do list. Case is not important.
    -o owner is the name of the person or group responsible for the item. It may contain spaces and is optional.

    -c category is the type of item, such as a UI task. It may contain spaces and is optional.

    Note: The to-do item text many not contain any character (or characters) that terminates a comment. .

    To-do list items you enter in the source code are added to the list as you type them. The to-do item text is added to the list. The status, priority, and owner are added if you specified them in the code.

    The order in which you specify owner and category is not important but the status (if included) must go first. The name of the module that contains the embedded item is automatically added to the to-do list. For single-line to-do list items, you can also precede the item with the // or /* comment delimiter.

    For example:

    /* TODO 2 -oNell: Implement stubbed out methods} */

    Creates a priority 2 to-do list item for which Nell is responsible and which says 揑mplement stubbed out methods.?

    /* Todo 1 -oSarah Alexander -cUI changes: Tell documentation about all changes/*

    Creates a priority 1 to-do list item for which Sarah Alexander is responsible and which says 揟ell documentation about all changes?

    When you put a check mark in the to-do list for the above item, the syntax in the source code changes to the following:

    /* DONE 1 -oSarah Alexander -cUI changes: Tell documentation about all changes } */

    You can also include to-do list items in a comment beginning with // in most cases. For example:

    //TODO 1 -oBoss: Resolve must fix bugs

    However, avoid nested to-do comments such as the following:

    //This is a comment within a comment. {TODO: This won't work!!}

    The nested to-do list item will not appear in the list in this case.

    好!
    顺便问一下我的cb2007 alt+f9不管用.必须点菜单是怎么回事?
    感觉没有冲突的热键啊.

    应该是自带的。不过由于装了cnpack后里面可以创建快照,所以都用快照搞定。

    jf

    汗………………我一直在用,以为大家也都知道………………

    汗………………我刚才知道,以为大家跟我一样也都不知道………………

    引用 27 楼 TR@SOE 的回复:
    汗………………我一直在用,以为大家也都知道………………

    %80的用户只用软件20%的功能,呵呵:-)

    这个功能不错,试试看.

    听说过,但是一直没有用到。很多习惯都是这样的。习惯的一些操作方法可能不是最便利的。

    是这样的,所以很多功能全的软件其实我们 都 没用到

    我05年时候发现的,
    不过忍住了没有共享(当时好多人发惊天大秘密和大家共享)

    我那个时候不知道todo的用法,后来看人家用vc的说可以写todo,我们的客户说代码提交的时候里面不能有todo
    就研究了下,发现了那个todo 嘿嘿。

    后来有什么todo* ? 等等经人家说,说是程序员约定俗成的,有的表示这里可能有莫名其妙的错误,没有测试到,没有想到
    有些是代表功能要做,汗一个。

    超级聚会啊!首脑会议!我也学习下!

    CB5好象就有了,然后一直用着。我也以为大家都用着了。

    学习&&接分不亦乐乎^^

    哦,CB自带的功能

    学习

    我才用一年,感觉上手挺快的

    以前略用过这个功能。

    早就发现了,不过还不够方便!

    ^-^

  • Filed under: C++ Builder
  • 在网上找了很多ThemeEngine 好象都没有bcb6可以用的,希望用过的人,告诉下如何安装和使用

    KSDev ThemeEngine v7.03 Full Source
    可以使Delphi/BCB编译的程序具windows XP界面风格。完整支持微软 Theme API。
    http://www.ccrun.com/view.asp?id=168

  • Filed under: C++ Builder
  • 如果单单是图标,
    ICON1  ICON  "gray.ico"
    ICON2  ICON  "blue.ico"
    ICON3  ICON  "orange.ico"
    链接的时候提示unknown rlink32 error

    如果是有图标和位图,
    ICON1  ICON  "gray.ico"
    ICON2  ICON  "blue.ico"
    ICON3  ICON  "orange.ico"
    BITMAP1  BITMAP  "bmp1.bmp"
    链接的时候提示cannot write to disk

    单单是位图的话链接正常

    也尝试过使用不同尺寸和不同色数(16*16,32*32,48*48,64*64,256,24bit,32bit)的图标,都不行。。。。

    按道理讲应该不会有问题,会不会你读资源的方式有问题呢,,

    用ImageList就可以了

    imagelist加入大的图片文件会死机。。。

    不存在读资源的方式,仅仅是把res文件加到工程里链接就出错啊,都没有去读

    编前别误删了资源文件本身

    没有删除,

    是否用了Vista的256×256压缩格式图标?

  • Filed under: C++ Builder
  • void __fastcall TMyThread::UploadFile()
    {

      Application->MessageBoxA("123","123",0);

    }

    //--------------------
    _fastcall TMyThread::TMyThread(bool CreateSuspended)
            :TThread(CreateSuspended)
    {
      FreeOnTerminate=true;
      Resume();
    }
    //--------------------
    void __fastcall TMyThread::Execute()
    {
      Synchronize(UploadFile);
    }

    代码如上

    加了断点,TMyThread::UploadFile()根本就没有被执行,如果在Synchronize(UploadFile);上加上断点,系统会变得很慢,直到程序被终止。

    我在想,是不是active form是通过ie调用的,本身就不是父进程,所以才会造成这种情况?

    请高手指点

    xabcxyz,我只是想在线程内访问active form上的组件,除了Synchronize外还有其他办法可以做到么?

    除了Synchronize外,borland好像没有提供其他手段

    我在Execute内直接调用的话会提示读越界………….

    郁闷,Synchronize在一般的vcl窗口程序里面每一点问题,到了active form就出问题了……….

    http://www.delphibbs.com/delphibbs/dispq.asp?lid=2724466

    这里已经讨论过这个问题了……….但是是基于delphi的

    active form里的线程是你编的,外边的线程也是你编的,干嘛不用命名TEvent同步呢?

    引用 6 楼 xabcxyz 的回复:
    active form里的线程是你编的,外边的线程也是你编的,干嘛不用命名TEvent同步呢?

    看了那个帖子里面的例子,不知道怎么用c++实现…….正在看资料

    我才摸了三天bcb…….

    http://explorer.javaeye.com/blog/106033

    按照这里的资料来看

    只要在ActiveForm中添加处理WM_NULL消息的处理过程,调用CheckSynchronize进行同步处理

    就没问题了,研究一下………

  • Filed under: C++ Builder
  • http://dn.codegear.com/cn/article/37236

      VCL Poster
    VCL Poster PDF 12 Mar 02 (129.1 KB)
    This is an updated Portable Document Format (PDF) version of the C++Builder 6 Hierarchy Chart. The 130K file replaces the BCB6VCLPoster.pdf file on your installation CD. You can download the file to any location on your hard disk (suggested location: \CBuilder6\Help). Adobe Acrobat Reader is required to view PDF files.

    顺便问个问题
    这个继承图里面为什么有很多抹掉的?
    DynamicArray,AnsiString为什么图里面都没有,这个图包含的还不是完全的吗?

    做什么的控件,看看去

    just look

  • Filed under: C++ Builder
  • 不要奇怪,我确实遇到了这样的问题,编译时出错了,错误定位在TEdit *edt1;这一行。

    问题描述:
    因为要用到API的SHBrowseForFolder函数,所以必须在#include <vcl.h>前加入一句:#define NO_WIN32_LEAN_AND_MEAN,问题来了,当我把TEdit控件的Name属性命名为edt1或edt11、edt12后(其实是CnPack推荐改名),编译出错了:[C++ Error] Unit1.h(14): E2040 Declaration terminated incorrectly。当我把Name属性改为edtt1或其他名字时(只要不是edt*都行),编译正常通过了!运行良好!贴出代码,各位可以试试自己的BCB6:

    C/C++ code
    Unit1.cpp //————————————————————————— #define NO_WIN32_LEAN_AND_MEAN //重要,目录函数需要 #include <vcl.h> #pragma hdrstop #include "Unit1.h" //————————————————————————— #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //————————————————————————— __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //—————————————————————————
    C/C++ code
    Unit1.h //————————————————————————— #ifndef Unit1H #define Unit1H //————————————————————————— #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> //————————————————————————— class TForm1 : public TForm { __published: // IDE-managed Components TEdit *edt1; private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); }; //————————————————————————— extern PACKAGE TForm1 *Form1; //————————————————————————— #endif

    如果代码中,把#define NO_WIN32_LEAN_AND_MEAN去掉,TEdit命什么名字都没有错误!
    怀疑是CnPack问题,卸载后问题依旧!

    我的编程环境:
    WINDOWS XP SP2
    BCB 6 + Update 4
    Indy 10.2.3
    CnPack IDE专家包 Ver: 0.8.3.374 Build 2008.04.01

    把#include <vcl.h>  放在  define NO_WIN32_LEAN_AND_MEAN  前面就可以了
    即调整一下顺序。

    引用 2 楼 thwen0101 的回复:
    把#include  <vcl.h>  放在  define NO_WIN32_LEAN_AND_MEAN⠠前面就可以了
    即调整一下顺序。

    把它们的顺序调整,那么SHBrowseForFolder就不能用了的。不信你试试。

    会不会与什么名字起冲突了。。。

    引用 4 楼 jacknes009 的回复:
    会不会与什么名字起冲突了。。。

    是呀,我估计也是,可是找不到原因啊?我的.CPP.H就是很简单的(如上)。真是郁闷啊。

    帮你顶了。。。

    我测试没问题,会不会是与其它控件冲突或项目设置问题

    同上

  • Filed under: C++ Builder
  • 如题.急啊….

    现在开发工具一出来我都在D版市场上花10元买D版来备用,这是个好习惯……

    晕啊!D版就不要钱啊!

    www.verycd.com上有

    现在开发工具一出来我都在D版市场上花10元买D版来备用,这是个好习惯……
    同意

    安装C++Builder_6的方法及下载C++Builder_6的地址
    http://www.zzg.3126.net/ShowFile.asp?FID=75

    软件我的态度是

    支持正版
    使用盗版

    不好意思,到这里下载C++Builder   2006   update   4终极版:

    http://www.zzg.3126.net/ShowFile.asp?FID=13

  • Filed under: C++ Builder
  • 用 BCB6 编译了盒子上下载的 4.98,但在使用时提示【[C++ Error] WinSkinData.hpp(289): E2293 ) expected】

    这一行是 void __fastcall ReadColor2(TShemeColor item, AnsiString key, Graphics::TColor default);

    是否是 TShemeColor 未定义?还是 Graphics::TColor 这个不对??怎么修改??

    不清楚你下载的那个版本文件是否完整,我手头的这份安装和使用都没有问题。不过由于涉及版权问题,不能在网站上共享了。

    看提示应该是TShemeColor类型的定义没有找到。

    恩,,好像我的也是噢,,没有解决噢,不知道怎么解决好噢,,

    我也在盒子下了個用,不過我用B2007編譯,記憶中一帆風順的,沒出什麼問題。 

    expected 這樣的提示,也太不明確原因是什麼發。
    或許需要你重新啟動後再編譯試試看。因為可能是編譯器或IDE本身出了異常。

  • Filed under: C++ Builder
  • 要写一个MP3播放器,时间有点紧,所以没法不用控件全部API来写了,谁用过这个控件,指点一下啦。

    直接用

    1楼的兄弟,能不能具体点,怎么写然后注册?
    2楼的,直接用的话我有点问题,因为我不要用它的界面,只是调用它的函数,我在自己的类里面这样写定义私有变量 TMediaPlayer* myPlayer;好像编不过,C#写多了,请教如何写?

    void __fastcall TForm1::PlayVoice()
    {
      AnsiString str = "a.wav";
          if(str.IsEmpty() &brvbar &brvbar !FileExists(str))
            return ;
          MediaPlayer1->FileName = str;
          try
          {
            MediaPlayer1->Open();
            MediaPlayer1->Play();
            MediaPlayer1->Notify = true;
          }
          catch(…){ return; }
    }

    我想把TMediaPlayer对象当参数传入类,不行吗?好像找不到TMediaPlayer类型。

    #include <MPlayer.hpp>

    没包头文件,我错了,BCB帮助实在太差。

    再问一下,如果我要播放MP3文件的话,好像只能把DeviceType 改成dtAutoSelect。但是我如果不预先指定FileName的话就会报错。如何解决这一问题,我要播放的文件是程序运行期给的。

    网上这样的例子挺多的,你搜索一下,也可参考delphi5开发人员指南上的例子

    继续提问,我自动播放歌曲用的是onNotify事件,每次play之后都会自动跳下一首。但是我把Notify设成false之后还是会触发这个事件,请教是何原因。

  • Filed under: C++ Builder
  • 类别

    最新

    标签

    链接


    存档