delphi数据库
delphi中如何相vb一样不用控件照样连接操作数据库。最好有代码。谢谢
看看下面我做的例子吧:
uses comobj;
procedure TForm1.Button1Click(Sender: TObject);
var
cn, rec : olevariant;
begin
cn := createOleObject('adodb.connection');
cn.open('driver={sql server};server=tc;DATABASE=asteras;Trusted_Connection=yes');
rec := createOleObject('adodb.recordset');
rec.open('select 123 as cn',cn);
showmessage(inttostr(rec.fields['cn'].value));
rec.close;
cn.close;
end;