从网上down个delphi7.0的,从网上找了半天的资料,可不是这不对就是那错,谁给我具体说说啊,连接到的数据库是(access/sql),先谢谢了。
解决方案 »
- vfw图像采集的问题
- TDBGridEh问题!
- 关于Access数据库的一个怪问题,忘大虾赐教
- 如何求的一报表中某个数值字段在每页中的和?
- 怎么直接取得局域网上其他机器中CPU和内存的占用情况?
- 控制光驱开关的简短代码
- 怎样把一个.mdf和.ldf文件导入sql server 2000里啊!
- 欢迎大家到c++builder版做客!!!散分100
- 疑惑中……为什么我的dbgrid的datasource一选定,就会令它的cellclick事件失灵??求救!!!!!
- 随机字符串的问题
- 那请问,把integer型参数,转成string型,用什么函数?
- 急急急(会websnap的请急速进来) !!!!!!!!
放一个Tadoconnection组件
设置其连接属性就能连上了
adoconnection.CommandTimeout := 15;
adoconnection.ConnectionTimeout := 15;
adoconnection.ConnectionString := '';
adoconnection.ConnectionString := 'Provider=SQLOLEDB.1;Password=' + Gpwd
+ ';Persist Security Info=True;User ID=' + Guser+ ';Initial Catalog=数据库名;Data Source=' + #39 + Gip+ #39;
try
if not adoconnection.Connected then adoconnection.Connected := true;
except
application.MessageBox('数据库连接失败!', Gsysname, mb_ok + mb_iconerror);
abort;
end;
总之方法很多,看看delphi自带的例子吧
var constr:string;
constr:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=';
constr:=constr+Edit1.text;//此处写登陆用户名
constr:=constr+';PASSWORD=';
constr:=constr+Edit2.text;//此处写登陆密码
constr:=constr+';Initial Catalog=';
constr:=constr+Edit3.text;//此处写要进入的数据库 如:tempdb
constr:=constr+';Data Source='+Edit4.text;//此处写数据源 可以写机器名,也可以是ip地址
ADOConnection1.Connected:=false;
ADOConnection1.LoginPrompt:=false;
ADOConnection1.ConnectionString:=constr;
ADOQuery1.Connection:=ADOConnection1;
ADOQuery1.SQL.Add('select passwd from table1');
ADOQuery1.open;
Edit1.text:=adoquery1.fields[0].asstring;
我告诉你怎么连。
我很菜可是还会连个数据库。
'D:\test.mdb;Persist Security Info=False;';
ADOQuery1.Connection:=ADOConnection1;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from testtable');
ADOQuery1.Open;
edit2.Text:=ADOQuery1.Fields[0].AsString;