|
procedure ConnDb (servername, userid, pwd, dbname: String);
var
ConnStr: string;
begin
try
ConnStr: = 'Provider = SQLOLEDB.1; Password =' + pwd +
'; Persist Security Info = False; User ID =' + Userid + '; Initial Catalog =' + DBName
+
'; Data Source =' + Servername;
ADOConnection1.ConnectionString: = ConnStr;
ADOConnection1.Connected: = true;
except
ShowMessage ('Unable to connect to the database!');
end;
end;
The above code is connected to the database. There are four character variables on it, but these variables cannot read the information from the machine into the program at all. In other words, the database cannot be connected. Let's see how to modify it to read the information correctly and connect to the database. |
|