谁有DELPHI和单独数据库SQL连接的实例的资料啊,要详细点的!一经采纳,10块大洋送出!谢谢!

2024-11-30 18:39:36
推荐回答(2个)
回答1:

ADO连接方式(连接sql server数据库)
AdoCon_Sys: TADOConnection; //数据库连接
……
AdoCon_Sys := TADOConnection.Create(Self);
AdoCon_Sys.ConnectionString := 'Provider = Sqloledb.1; Password = ' + DBPW +
';Persist Security Info = True; User Id = ' + DbUser + '; Initial Catalog = '
+ DBName + '; Data Source = ' + DataBaseIP;
AdoCon_Sys.LoginPrompt := False;
try
AdoCon_Sys.Connected := True;
except
MessageBox(Handle, '数据库连接失败,请检查网络或者配置!', '数据库连接提示', 0);
Can_Connect_Server := False;
end;

AdoQry: TADOQuery;
……
AdoQry:= TADOQuery.Create(nil);
AdoQry.ConnectionString := AdoCon_Sys.ConnectionString;
//或者AdoQry.Connection := AdoCon_Sys;
try
AdoQry.Close;
AdoQry.SQL.Text := '……';
AdoQry.Open;
While Not AdoQry.Eof Do
Begin
……

AdoQry.Next;
End;

finally
AdoQry.Active := False;
AdoQry.Free;
end;

回答2:

单独数据库是什么数据库?
sqlserver?
很简单的