ADO 怎么和SQLSERVER连接呀? 都要用代码实现。谁有详细的资料呢?和其他的数据库连接的最好也有嘻嘻~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.csdn.net/develop/Read_Article.asp?Id=9285与sql server连接可将文章中的AConnection.Open('Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\inetpub\wwwroot\test');改为AConnection.Open("Provider=SQLOLEDB.1;Persist Security Info=False;User ID=用户名;Password=密码;Initial Catalog=库名;Data Source=服务器ip"); unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DB, ADODB;type TForm1 = class(TForm) ADOConnection1: TADOConnection; labelededit1: TEdit; labelededit2: TEdit; Button1: TButton; Button2: TButton; Label1: TLabel; Label2: TLabel; Edit1: TEdit; Label3: TLabel; Edit2: TEdit; Label4: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);varstr:string;beginif (labelededit1.Text<>'') and (labelededit2.Text<>'') thenbegin//连接远程服务器:str:='Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'+';'+'User ID='+LabeledEdit1.Text+';'+'Password='+labelededit2.text+';'+'Initial Catalog=数据库名称'+';'+'Data Source=服务器名称';str:='Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'+';'+'User ID='+LabeledEdit1.Text+';'+'Password='+labelededit2.text+';'+'Initial Catalog='+edit2.Text+';'+'Data Source='+EDIT1.Text;ADOConnection1.ConnectionString:=str;ADOConnection1.Open;labelededit2.Text:='';Button1.Enabled:=false;end;end;procedure TForm1.Button2Click(Sender: TObject);beginADOConnection1.Close;Button1.Enabled:=true;end;end.下一篇::用ADOConnection连接到具体数据库: procedure Tloginmain.Button1Click(Sender: TObject);varstr:string;beginif (labelededit1.Text<>'') and (labelededit1.Text<>'') thenbegin//连接远程服务器:str:='Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'+';'+'User ID='+LabeledEdit1.Text+';'+'Password='+labelededit2.text+';'+'Initial Catalog=数据库名称'+';'+'Data Source=服务器名称';str:='Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'+';'+'User ID='+LabeledEdit1.Text+';'+'Password='+labelededit2.text+';'+'Initial Catalog=testdase';ADOConnection1.ConnectionString:=str;ADOConnection1.Open;labelededit2.Text:='';end;end;断开数据库:procedure Tloginmain.Button2Click(Sender: TObject);beginADOConnection1.Close;Button1.Enabled:=true; end;具体连接到数据库的某个表可以用:ADODataSet将ADODataSet的Connection属性设置为:ADOConnection将ADODataSet的CommandType属性设置为:cmdTableif not loginmain.ADODataSet1.Active thenbeginADODataSet1.CommandText:='worker_information';//worker_information为表名ADODataSet1.Open;end; Provider=SQLOLEDB.1Persist Security Info=False上面两句是什么意思?Provider=SQLOLEDB.1 这句是不是指定SQL的驱动?除了上面你说的那种方法还有其他方法吗? Driver={SQL erver};Description=sqldemo;SERVER=127.0.0.1;UID=LoginID; PWD=Password;DATABASE=Database_Name AConnection.Open("DRIVER=SQL Server;SERVER=数据库服务器名;DATABASE=数据库名;User Id=用户名;PASSWORD=密码;") 更正:AConnection.Open("DRIVER={SQL Server};ERVER=数据库服务器名;DATABASE=数据库名;User Id=用户名;PASSWORD=密码;") ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=sa;Initial Catalog=mAppTemplate;Data Source=RKDB';ADOConnection1.Open; 如果你装的是8i的话,8i本身带了提供者,Oracle Provider for ole db:Provider=OraOLEDB.Oracle.1;Password=;Persist Security Info=True;User ID=system;Data Source=rkdb 整理了以下嘻~myconn.open('Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=master;Data Source=a6mm;');或者myconn.Open('DRIVER=SQL Server;SERVER=a6mm;DATABASE=master;User Id=sa;') QuickBurro V3.22发布,正式版继续免费! 操作文件问题,急, 动态创建Tquery对象问题??? 在ActiveX中使用URLDownLoadToFile函数中的参数问题 在DBGrid中如何显示Memo字段值? 怎样对多表查询的结果进行递交更新 用户注册密码或信息加密问题 关于日期型转换成整形的问题!!!!重分!!!! 关于”嵌入Exe,Exe程序里的全部模态窗体失效!!!“的问题? 请问用什么命令来检索表中的字段名。 如何备份SQL数据库中的某一个表 和我一样在公司加班练活的兄弟请看看......编写非可视化组建,各位给点儿思路吧。
AConnection.Open('Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\inetpub\wwwroot\test');
改为
AConnection.Open("Provider=SQLOLEDB.1;Persist Security Info=False;User ID=用户名;Password=密码;Initial Catalog=库名;Data Source=服务器ip");
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
labelededit1: TEdit;
labelededit2: TEdit;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
str:string;
begin
if (labelededit1.Text<>'') and (labelededit2.Text<>'') then
begin
//连接远程服务器:str:='Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'+';'+'User ID='+LabeledEdit1.Text+';'+'Password='+labelededit2.text+';'+'Initial Catalog=数据库名称'+';'+'Data Source=服务器名称';str:='Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'+';'+'User ID='+LabeledEdit1.Text+';'+'Password='+labelededit2.text+';'+'Initial Catalog='+edit2.Text+';'+'Data Source='+EDIT1.Text;ADOConnection1.ConnectionString:=str;ADOConnection1.Open;labelededit2.Text:='';
Button1.Enabled:=false;end;end;procedure TForm1.Button2Click(Sender: TObject);
begin
ADOConnection1.Close;Button1.Enabled:=true;end;end.
下一篇::
用ADOConnection连接到具体数据库: procedure Tloginmain.Button1Click(Sender: TObject);varstr:string;beginif (labelededit1.Text<>'') and (labelededit1.Text<>'') thenbegin//连接远程服务器:str:='Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'+';'+'User ID='+LabeledEdit1.Text+';'+'Password='+labelededit2.text+';'+'Initial Catalog=数据库名称'+';'+'Data Source=服务器名称';str:='Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'+';'+'User ID='+LabeledEdit1.Text+';'+'Password='+labelededit2.text+';'+'Initial Catalog=testdase';ADOConnection1.ConnectionString:=str;ADOConnection1.Open;labelededit2.Text:='';end;end;断开数据库:
procedure Tloginmain.Button2Click(Sender: TObject);beginADOConnection1.Close;Button1.Enabled:=true; end;
具体连接到数据库的某个表可以用:ADODataSet将ADODataSet的Connection属性设置为:ADOConnection将ADODataSet的CommandType属性设置为:cmdTableif not loginmain.ADODataSet1.Active thenbeginADODataSet1.CommandText:='worker_information';//worker_information为表名ADODataSet1.Open;end;
Persist Security Info=False
上面两句是什么意思?
Provider=SQLOLEDB.1 这句是不是指定SQL的驱动?除了上面你说的那种方法还有其他方法吗?
PWD=Password;DATABASE=Database_Name
AConnection.Open("DRIVER={SQL Server};ERVER=数据库服务器名;DATABASE=数据库名;User Id=用户名;PASSWORD=密码;")
ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=sa;Initial Catalog=mAppTemplate;Data Source=RKDB';
ADOConnection1.Open;
Provider=OraOLEDB.Oracle.1;Password=;Persist Security Info=True;User ID=system;Data Source=rkdb
嘻~
myconn.open('
Provider=SQLOLEDB.1;
Persist Security Info=False;
User ID=sa;
Initial Catalog=master;
Data Source=a6mm;
');
或者
myconn.Open('
DRIVER=SQL Server;
SERVER=a6mm;
DATABASE=master;
User Id=sa;
')