מה תרצה/י לחפש?
Setting Up for the PrintBOS Applicative User
Setting Up the Environment for the Applicative User
MS SQL Express Settings
1. Change SQL Server Properties
Security Settings
Follow these steps to enable SQL Server authentication:
- Open SQL Server Management Studio.
- Right-click on the server and select Properties.
- Navigate to the Security tab.
- Select
SQL Server and Windows Authentication mode.
2. Add New SQL Authentication User
Under Server -> Security -> Logins
To create a new SQL authentication user:
- Right-click Logins and select New Login….
- Under the General page:
- Enter the username under Login Name.
- Select
SQL Server authentication. - Set a password and uncheck
User must change password at next login.
- Under User Mapping:
- Select the database under Users mapped to this login:.
- Select
publicanddb_ownerunder Database role membership for: the database name.
Test Connection
Use the following PowerShell script to test the database connection:
$serverName = '.\SQLEXPRESS'
$databaseName = 'PrintBOS'
$username = 'PrintBOS_SQL'
$password = 'password'
# Convert the cleartext password to SecureString
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
# Create SQL connection
$connectionString = "Server=$serverName;Database=$databaseName;User Id=$username;Password=$password;TrustServerCertificate=True"
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
try {
# Attempt to open the connection
Write-Output "[INFO] Attempting to open SQL connection..."
$connection.Open()
Write-Output "[SUCCESS] Database connection successfully established."
# Additional code...
}
catch {
Write-Output "[ERROR] Error during connection or command execution: $_.Exception.Message"
Write-Output "[ERROR] Full Exception: $_.Exception.ToString()"
}
finally {
if ($connection.State -eq [System.Data.ConnectionState]::Open) {
$connection.Close()
Write-Output "[INFO] Database connection closed."
}
}
# Display a message indicating script completion
Write-Output "[INFO] Script execution completed."
Expected Result
Upon successful execution, the script should display the following messages:
[INFO] Attempting to open SQL connection...
[SUCCESS] Database connection successfully established.
[INFO] Database connection closed.
[INFO] Script execution completed.