问题
我有DBGdrid并且有ID's从 MS Access 数据库显示的列。如何将它们更改为真实值,例如item name, client name, employee name?
我有代码(测试代码,我只是尝试从表中获取所有项目名称,我可以将它们保存到数组或变量中,并更改DBGrid显示 id 的值),但我不知道如何更改DBGrid值字段。
procedure TForm2.Button1Click(Sender: TObject);
var i,j:integer; mas:string;
begin
Button1.Enabled := false;
Button2.Enabled := true;
Button3.Enabled := true;
Form1.ADOQuery1.SQL.Text := 'SELECT * FROM items_specification';
Form1.ADOQuery1.Open;
j:= Form1.ADOQuery1.RecordCount;
Form1.ADOQuery1.Close;
i:=1;
repeat
Form1.ADOQuery1.SQL.Text := 'SELECT * FROM items_specification WHERE item_id = :ID';
Form1.ADOQuery1.Parameters.ParamByName('ID').Value := i;
Form1.ADOQuery1.Open;
mas:= Form1.ADOQuery1['item_name'];
Form1.ADOQuery1.Close;
inc(i);
ShowMessage(mas) ;
until (i = j+1);
Run Code Online (Sandbox Code Playgroud)
也许您对如何解决问题有任何建议,我将不胜感激。
在 MS Access 中,我已经查找以 …
我想使用 C++ 更改任何 Linux 用户密码,任何解决方案都会很棒。
我需要手动完成,这意味着打开文件(不能使用 system()):
似乎我也需要锁定这些文件。有打开.txt文件和读取内容的c代码示例,但无法读取大内容,这也是问题。
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/file.h>
#include <stdlib.h>
#include <string>
const char* path = "/tmp/log.txt";
void read_file()
{
int fd;
char buf[1000];
int i;
fd = open(path, O_RDONLY);
flock(fd, LOCK_SH);
for(i=0; i < 255 ; i++) {
read(fd, &buf[i], 1);
usleep(10 * 10); // 10 ms
}
flock(fd, LOCK_UN);
close(fd);
printf("reader: %#x: %s\n", getpid(), buf);
usleep(10 * 10); // 10 ms
}
void reader()
{
read_file();
exit(0); …Run Code Online (Sandbox Code Playgroud)