- Print
- PDF
Create a Microsoft SQL Server Database for Autoform DM
This page describes how to create a Microsoft SQL Server database for Autoform DM to use.
In summary, the process has the following stages:
Create the database.
Create the database user (that Autoform DM will connect to the database as).
Assign database roles to the user.
You can create the database and user manually (through various windows in SQL Server Management Studio). Or, if you prefer, you can run a SQL script.
Before You Begin
Ensure that the Microsoft SQL Server instance that you want to use has been created and is running. Then, start SQL Server Management Studio and connect to the instance as a user that is able to create databases and users.
You can now follow the manual method or SQL command method of creating the Autoform DM database and user.
Manual Method
The following sections describe how to manually create the database and user.
Manually Create the Database
To create the database, follow these steps:
Start Microsoft SQL Server Management Studio and connect to the relevant instance.
In the Object Explorer pane, right-click Databases, then select New Database. The New Database window opens.
On the General page, enter a Database name for the new database. The Autoform DM installer assumes that the database name is
AFPDM
, so enter AFPDM (unless you want to give the database a different name). If you do use a different name, ensure that you enter that same name when you later install Autoform DM.Click OK.
Manually Create the Database User for Autoform DM
To create the database user, follow these steps:
In the Object Explorer pane, expand Security.
Right-click Logins, then select New Login. The Login - New window opens.
Select the General page, then configure the new user:
Enter a Login name. The default name used by the Autoform DM installer is
pdm
. Unless you want to use a different name (see warning below), enter pdm.Click SQL Server authentication.
Enter a password into Password and Confirm Password. The default password used by the Autoform DM installer is
pdm
. Unless you want to use a different password (see warning below), enter pdm.Warning
If you enter a Login name or password other than the default
pdm
(for example, to mitigate any security risks around using the default credentials), ensure that you enter those same credentials later in the Autoform DM installer.
It is strongly advised that you use a strong password (instead of the defaultpdm
). Password policy features in SQL Server are also available to you in this window. However, you must not select User must change password at next login.In the Default database list, select the database that you created. For example, AFPDM.
Select the Server Roles page, then select the public checkbox.
Select the User Mappings page, then configure the new user:
In the upper table, click the AFPDM row.
In that row, select the Map checkbox.
Ensure that the AFPDM row is still selected. Then, select the following checkboxes in the lower part of the window:
db_ddladmin
db_datareader
db_datawriter
Click OK to create the user.
SQL Command Method
To use SQL commands to create the database and user (instead of the manual method described above), run the following SQL script in SQL Server Management Studio.
Warning
In the SQL commands, you must make the following substitutions:
Substitute
<databasename>
for the database name that you want to use. For example:
SET @DatabaseName = '<databasename>';
becomesSET @DatabaseName = 'AFPDM';
Substitute<username>
for the user name that you want to use. For example:
SET @Username = '<username>';
becomesSET @Username = 'pdm';
Substitute<password>
for the password that you want to use. For example:
SET @Password = '<password>';
becomesSET @Password = 'YourSecurePassword';
Warning
Your system might be configured with a password complexity policy that causes SQL Server to reject your chosen password. If you run the script but the Messages pane contains an error related to password validation, you must change the password in the script so that it complies with SQL Server password complexity rules, then run the updated script.
SQL script:
DECLARE @DatabaseName VARCHAR(50);
DECLARE @Username NVARCHAR(50);
DECLARE @Password NVARCHAR(50);
SET @DatabaseName = '<databasename>';
SET @Username = '<username>';
SET @Password = '<password>'; -- Ensure you set a secure password here
DECLARE @SQL NVARCHAR(MAX);
-- Create database if it does not exist
IF NOT EXISTS (SELECT name FROM sys.databases WHERE name = @DatabaseName)
BEGIN
SET @SQL = 'CREATE DATABASE [' + @DatabaseName + ']';
EXEC sp_executesql @SQL;
END
-- Create login if it does not exist
IF NOT EXISTS (SELECT name FROM sys.server_principals WHERE name = @Username)
BEGIN
SET @SQL = 'CREATE LOGIN [' + @Username + '] WITH PASSWORD = ''' + @Password + ''', DEFAULT_DATABASE = [' + @DatabaseName + ']';
EXEC sp_executesql @SQL;
END
-- Create user mapped onto database and assign appropriate roles if user does not exist
SET @SQL = 'USE [' + @DatabaseName + ']; ' +
'IF NOT EXISTS (SELECT name FROM sys.database_principals WHERE name = ''' + @Username + ''') ' +
'BEGIN ' +
'CREATE USER [' + @Username + '] FOR LOGIN [' + @Username + ']; ' +
'EXEC sp_addrolemember ''db_ddladmin'', ''' + @Username + '''; ' +
'EXEC sp_addrolemember ''db_datareader'', ''' + @Username + '''; ' +
'EXEC sp_addrolemember ''db_datawriter'', ''' + @Username + '''; ' +
'END';
EXEC sp_executesql @SQL;
Troubleshooting
If user roles have been incorrectly assigned, Autoform DM will write failure messages to its logs in particular situations:
When Autoform DM starts for the first time (as a new installation or after an upgrade)
Failure messages related to logging into the database.
Failure messages related to creating tables and database objects.
During administration operations such as adding or removing key definitions
Failure messages related to modifying the
tblDocuments
ortblDocumentHistory
tables.
If you see these messages in the logs, check that users have been created and that they have the correct role assignments:
In the Object Explorer pane, expand Databases, then expand the new database.
Expand Security > Users, right-click the new user (pdm), then select Properties from the menu. The Database User - pdm window opens.
On the General page, check that Default schema is dbo. This is the correct setting for a standard setup of Autoform DM.
On the Membership page, check that the following role checkboxes are selected:
db_ddladmin
db_datareader
db_datawriter