| |

VerySource

 Forgot password?
 Register
Search
View: 860|Reply: 3

Let's take a look at this code

[Copy link]

3

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-3 19:30:01
| Show all posts |Read mode
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.
Reply

Use magic Report

0

Threads

15

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-3 20:27:01
| Show all posts
I think there is no error in the above syntax. It may be that your parameters are incorrect and the connection fails. Use the following dynamic settings to see:
ADOConnection1.Connected: = false;
ADOConnection1.ConnectionString: = PromptDataSource (Handle, ADOConnection1.ConnectionString);
ADOConnection1.Connected: = true;
Where Handle is the window handle
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-4 09:12:01
| Show all posts
Is your ODBC set up?
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-5-20 08:00:01
| Show all posts
What about your datasource?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list