In all lessons with a SQL Server database connection, you will have a Connection string supplied to you with the database and table SQL scripts so that you can follow along with the code provided in the lesson.
(The names below will change depending on the lesson you are doing, but all will be similar) SQL Server.
[Step 1]:
Create a new Database named [Test]
Right-click on [Databases]
Choose [New Database]
When Dialog opens - Database Name: Test
Choose [OK]
[Step 2]:
Create a new SQL Server Database user named [testuser]
Right-click on [Security]
Choose [New] | [Login]
Login name: testuser
Select [SQL Server authentication]
password: testuser
confirm password: testuser
Under [Select a page]
Choose [Server Roles]
Add a check to [sysadmin]
Next - Choose [User Mapping]
From the [User mapped to this login]
Choose the [Test] database.
Click [OK]
[Step 3]: Right-click on the new database [Test] Choose [New Query] Copy and paste the code from the [SQL] tab into the Query window, and click on [Execute] You should now have a table called Tags with nine records.
[Step 4]: Create our connection string to our newly created database. In a new file, copy and paste the code. Classic ASP Top of the [ASP] tab and save the file as [ACN.asp] Top of the [ASP.NET] tab and save the file as [database.config]
The items below need to be changed to your system specs.
[getServer] = this is the Computer (or) Server name.
[getInstance] = This is the SQL Server instance name.
username = "USERNAME"
password = "PASSWORD"
(ALWAYS-ON-LISTENER = This is the listener name if you have set up the "Always On High Availability" Group)
getSerInstance = "ALWAYS-ON-LISTENER,2433" (OR) "SERVER-NAME\INSTANCE-NAME"Set siteconn = CreateObject("ADODB.Connection")
siteconn.Open("Provider=SQLOLEDB; Data Source="&getSerInstance&"; Initial Catalog=New-CS;User ID="&username&";Password="&password&";")
VB and C# (Copy and paste and save as database.config, then refer to this file from Web.config)