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;
单独数据库是什么数据库?
sqlserver?
很简单的