Skip to content

Commit 2fd309a

Browse files
authored
Merge pull request #11187 from MightyPen/july07i
Fix Issue 2389, Node.js connect. From abandoned public PR 2585 (David-Engel).
2 parents a911392 + ea37ddc commit 2fd309a

1 file changed

Lines changed: 42 additions & 18 deletions

File tree

docs/connect/node-js/step-3-proof-of-concept-connecting-to-sql-using-node-js.md

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Step 3: Proof of concept connecting to SQL using Node.js | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "08/08/2017"
4+
ms.date: "07/23/2019"
55
ms.prod: sql
66
ms.prod_service: connectivity
77
ms.reviewer: ""
@@ -26,15 +26,23 @@ The **new Connection** function is used to connect to SQL Database.
2626
```javascript
2727
var Connection = require('tedious').Connection;
2828
var config = {
29-
userName: 'yourusername',
30-
password: 'yourpassword',
31-
server: 'yourserver.database.windows.net',
32-
// If you are on Microsoft Azure, you need this:
33-
options: {encrypt: true, database: 'AdventureWorks'}
29+
server: 'your_server.database.windows.net', //update me
30+
authentication: {
31+
type: 'default',
32+
options: {
33+
userName: 'your_username', //update me
34+
password: 'your_password' //update me
35+
}
36+
},
37+
options: {
38+
// If you are on Microsoft Azure, you need encryption:
39+
encrypt: true,
40+
database: 'your_database' //update me
41+
}
3442
};
3543
var connection = new Connection(config);
3644
connection.on('connect', function(err) {
37-
// If no error, then good to proceed.
45+
// If no error, then good to proceed.
3846
console.log("Connected");
3947
});
4048
```
@@ -48,12 +56,20 @@ All SQL statements are executed using the **new Request()** function. If the sta
4856
```javascript
4957
var Connection = require('tedious').Connection;
5058
var config = {
51-
userName: 'yourusername',
52-
password: 'yourpassword',
53-
server: 'yourserver.database.windows.net',
54-
// When you connect to Azure SQL Database, you need these next options.
55-
options: {encrypt: true, database: 'AdventureWorks'}
56-
};
59+
server: 'your_server.database.windows.net', //update me
60+
authentication: {
61+
type: 'default',
62+
options: {
63+
userName: 'your_username', //update me
64+
password: 'your_password' //update me
65+
}
66+
},
67+
options: {
68+
// If you are on Microsoft Azure, you need encryption:
69+
encrypt: true,
70+
database: 'your_database' //update me
71+
}
72+
};
5773
var connection = new Connection(config);
5874
connection.on('connect', function(err) {
5975
// If no error, then good to proceed.
@@ -97,11 +113,19 @@ In this example you will see how to execute an [INSERT](../../t-sql/statements/i
97113
```javascript
98114
var Connection = require('tedious').Connection;
99115
var config = {
100-
userName: 'yourusername',
101-
password: 'yourpassword',
102-
server: 'yourserver.database.windows.net',
103-
// If you are on Azure SQL Database, you need these next options.
104-
options: {encrypt: true, database: 'AdventureWorks'}
116+
server: 'your_server.database.windows.net', //update me
117+
authentication: {
118+
type: 'default',
119+
options: {
120+
userName: 'your_username', //update me
121+
password: 'your_password' //update me
122+
}
123+
},
124+
options: {
125+
// If you are on Microsoft Azure, you need encryption:
126+
encrypt: true,
127+
database: 'your_database' //update me
128+
}
105129
};
106130
var connection = new Connection(config);
107131
connection.on('connect', function(err) {

0 commit comments

Comments
 (0)