T
tdtdtdtdtd
Unregistered / Unconfirmed
GUEST, unregistred user!
这是一个窗体的FormCreate事件的代码,每次它执行到第4个FieldByName时就会报错,很准确,无论第4个FieldByName的参数是什么:
-------------------------
sql:= 'select * from pacts';//pacts有32个字段
ClientDataSet_pact.CommandText := strsql;
ClientDataSet_pact.Open;//此处正常,中断后在watch里可以看到ClientDataSet_pact里面正确的值
self.Edit_title.Text := ClientDataSet_pact.FieldByName('title').AsString;
self.Edit_pact.Text :=ClientDataSet_pact.FieldByName('pact').AsString;
self.Edit_account_dj.Text := ClientDataSet_pact.FieldByName('account_dj').AsString;
self.Edit_account_qy.Text := ClientDataSet_pact.FieldByName('account_qy').Asstring;//这一句抛出异常,如果注释这一句,则下一句抛出异常,如果注释前面四句,则向下数第4句抛出异常‘cannot perform this operation a closed dataset’
self.Edit_customer.Text :=ClientDataSet_pact.FieldByName('customer').AsString;
self.Edit_E_customer.Text :=ClientDataSet_pact.FieldByName('E_customer').AsString;
self.Edit_address.Text :=ClientDataSet_pact.FieldByName('address').AsString;
self.Edit_E_addr.Text :=ClientDataSet_pact.FieldByName('E_addr').AsString;
self.Edit_Ob_addr.Text :=ClientDataSet_pact.FieldByName('Ob_addr').AsString;
self.Edit_eob_addr.Text:=ClientDataSet_pact.FieldByName('eob_addr').AsString;
self.Edit_total.Text:=ClientDataSet_pact.FieldByName('total').AsString;
self.Edit_insurance.Text:=ClientDataSet_pact.FieldByName('insurance').AsString;
self.Edit_insurance.ItemIndex:=ClientDataSet_pact.FieldByName('insurance').AsInteger;
self.Edit_method.ItemIndex:=ClientDataSet_pact.FieldByName('method').AsInteger;
self.Edit_Lc_date.Date:=strtodate(ClientDataSet_pact.FieldByName('Lc_date').AsString);
self.Edit_lc_day.Text:=ClientDataSet_pact.FieldByName('lc_day').AsString;
self.Edit_bxf.Text:=ClientDataSet_pact.FieldByName('bxf').AsString;
self.Edit_yf.Text:=ClientDataSet_pact.FieldByName('yf').AsString;
self.Edit_sp_money.Text:=ClientDataSet_pact.FieldByName('sp_money').AsString;
self.Edit_moneyid.Text:=ClientDataSet_pact.FieldByName('moneyid').AsString;
self.Edit_schedule.ItemIndex:=ClientDataSet_pact.FieldByName('schedule').AsInteger;
我的窗口里面有7个ClientDataSet,这个是首先处理的
-------------------------
sql:= 'select * from pacts';//pacts有32个字段
ClientDataSet_pact.CommandText := strsql;
ClientDataSet_pact.Open;//此处正常,中断后在watch里可以看到ClientDataSet_pact里面正确的值
self.Edit_title.Text := ClientDataSet_pact.FieldByName('title').AsString;
self.Edit_pact.Text :=ClientDataSet_pact.FieldByName('pact').AsString;
self.Edit_account_dj.Text := ClientDataSet_pact.FieldByName('account_dj').AsString;
self.Edit_account_qy.Text := ClientDataSet_pact.FieldByName('account_qy').Asstring;//这一句抛出异常,如果注释这一句,则下一句抛出异常,如果注释前面四句,则向下数第4句抛出异常‘cannot perform this operation a closed dataset’
self.Edit_customer.Text :=ClientDataSet_pact.FieldByName('customer').AsString;
self.Edit_E_customer.Text :=ClientDataSet_pact.FieldByName('E_customer').AsString;
self.Edit_address.Text :=ClientDataSet_pact.FieldByName('address').AsString;
self.Edit_E_addr.Text :=ClientDataSet_pact.FieldByName('E_addr').AsString;
self.Edit_Ob_addr.Text :=ClientDataSet_pact.FieldByName('Ob_addr').AsString;
self.Edit_eob_addr.Text:=ClientDataSet_pact.FieldByName('eob_addr').AsString;
self.Edit_total.Text:=ClientDataSet_pact.FieldByName('total').AsString;
self.Edit_insurance.Text:=ClientDataSet_pact.FieldByName('insurance').AsString;
self.Edit_insurance.ItemIndex:=ClientDataSet_pact.FieldByName('insurance').AsInteger;
self.Edit_method.ItemIndex:=ClientDataSet_pact.FieldByName('method').AsInteger;
self.Edit_Lc_date.Date:=strtodate(ClientDataSet_pact.FieldByName('Lc_date').AsString);
self.Edit_lc_day.Text:=ClientDataSet_pact.FieldByName('lc_day').AsString;
self.Edit_bxf.Text:=ClientDataSet_pact.FieldByName('bxf').AsString;
self.Edit_yf.Text:=ClientDataSet_pact.FieldByName('yf').AsString;
self.Edit_sp_money.Text:=ClientDataSet_pact.FieldByName('sp_money').AsString;
self.Edit_moneyid.Text:=ClientDataSet_pact.FieldByName('moneyid').AsString;
self.Edit_schedule.ItemIndex:=ClientDataSet_pact.FieldByName('schedule').AsInteger;
我的窗口里面有7个ClientDataSet,这个是首先处理的