type
  Tkcxg = class(TForm)
    DBGrid1: TDBGrid;
    insert: TButton;
    dbna1: TDBNavigator;
    BitBtn1: TBitBtn;
    procedure insertClick(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  kcxg: Tkcxg;implementation
   uses datajh;
{$R *.DFM}procedure Tkcxg.insertClick(Sender: TObject);
begin
data_jh.work_s.DataSet:=data_jh.work;
       with data_jh.work  do
begin
Close;
with data_jh do
begin
course.Active:=false;
couse_type.Active:=false;
specialty.Active:=false;
course.ReadOnly:=false;
couse_type.ReadOnly:=false;
specialty.ReadOnly:=false; 
course.Active:=true;
couse_type.Active:=true;
specialty.Active:=true;
end;
DatabaseName:='f:\data';
sql.Clear;
SQL.LoadFromFile('f:\data\courseedit.txt');
prepare;
Open;end;
end;courseedit.txt的内容如下SELECT Course.Course_name, Course.Course_credit, Course.Course_term, Course.Course_id, Specialty.Specialty_name, Course_type.Course_type
FROM "f:\data\course.DB" Course
   INNER JOIN "f:\data\course_type.DB" Course_type
   ON  (Course.Course_id = Course_type.Course_id)  
   INNER JOIN "f:\data\specialty.DB" Specialty
   ON  (Course_type.Specialty_id = Specialty.Specialty_id) 
如果我执行data_jh.work.insert;就出错误,它报错误,不能打开只读的dataset
当执行insert时,是不是对Course.Course_id, Course_type.Course_id都赋值了?
我现在想对Course.Course_id赋值时,course_type.course_id自动赋予相同的值,怎么做?
问题二?
能否在dbgrid中加个dbcomobox一栏?
问题三?
如果用UpdateSQL1,query怎么使用呢?delphi的UpdateSQL例子中,执行时候他叫我输入密码?

解决方案 »

  1.   

    1、data_jh.work是一个查询(query)吧!如果是的话需要打开一个叫Requestlive的属性,将它设置为真才能插入和修改!
    Course.Course_id要自动给值的话只能在数据库里完成,你用SQLServer吗?
    2、dbgrid中想要一个dbcomobo吗?还是用Ehlib组件吧,它可以做的到,很好用的!没有的话向我要!
    3、那东西我没用过,因为没有必要用它!你的程序太长了,很难看呢!呵呵~~~!
      

  2.   

    query 数据集合是dbgrid的,我现在就是要对dbgrid修改!
    ehlib在哪里下谢谢了!